package cn.source.system.service.impl;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import cn.source.common.core.domain.AjaxResult;
import cn.source.system.domain.*;
import cn.source.system.mapper.*;
import cn.source.system.service.*;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.excel.EasyExcel;
import com.google.gson.Gson;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.source.majors.domain.SMajors;
import cn.source.majors.domain.SMajorsZk;
import cn.source.majors.mapper.SMajorsMapper;
import cn.source.majors.mapper.SMajorsZkMapper;
import cn.source.school.domain.School;
import cn.source.school.mapper.SchoolMapper;


/**
 * 年度学校录取情况Service业务层处理
 * 
 * @author sourcebyte.vip
 * @date 2024-02-20
 */
@Service
public class SchoolYearAdmissionServiceImpl implements ISchoolYearAdmissionService 
{
	
	private static final Logger log = LoggerFactory.getLogger(SchoolYearAdmissionServiceImpl.class);
	
    @Autowired
    private SchoolYearAdmissionMapper schoolYearAdmissionMapper;
    
    @Autowired
    private SchoolMajorYearAdmissionMapper schoolMajorYearAdmissionMapper;
    
    @Autowired
    private SchoolMajorYearAdmissionDetailMapper schoolMajorYearAdmissionDetailMapper;
    
    @Autowired
    private GkGradeDocMapper gkGradeDocMapper;
    
    @Autowired
    private SMajorsMapper majorsMapper;
    
    @Autowired
    private SMajorsZkMapper majorsZkMapper;
    
    @Autowired
    private SchoolMapper schoolMapper;
    
    @Autowired
    private SchoolPlanMapper schoolPlanMapper;
    
    @Autowired
    private SchoolPlanZkMapper schoolPlanZkMapper;
    
    
    @Autowired
    private SchoolYearAdmissionZkMapper schoolYearAdmissionZkMapper;
    
    @Autowired
    private SchoolMajorYearAdmissionZkMapper schoolMajorYearAdmissionZkMapper;
    
    @Autowired
    private SchoolMajorYearAdmissionDetailZkMapper schoolMajorYearAdmissionDetailZkMapper;

	@Autowired
	private SchoolZyzYearAdmissionMapper schoolZyzYearAdmissionMapper;

	@Autowired
	private ISchoolPlanService schoolPlanService;

	@Autowired
	private ISchoolMajorYearAdmissionService schoolMajorYearAdmissionService;

	@Autowired
	private IGkGradeDocService gkGradeDocService;

	@Autowired
	ISchoolZyzYearAdmissionService schoolZyzYearAdmissionService;

    /**
     * 查询年度学校录取情况
     * 
     * @param id 年度学校录取情况主键
     * @return 年度学校录取情况
     */
    @Override
    public SchoolYearAdmission selectSchoolYearAdmissionById(Long id)
    {
        return schoolYearAdmissionMapper.selectSchoolYearAdmissionById(id);
    }

    /**
     * 查询年度学校录取情况列表
     * 
     * @param schoolYearAdmission 年度学校录取情况
     * @return 年度学校录取情况
     */
    @Override
    public List<SchoolYearAdmission> selectSchoolYearAdmissionList(SchoolYearAdmission schoolYearAdmission)
    {
        return schoolYearAdmissionMapper.selectSchoolYearAdmissionList(schoolYearAdmission);
    }

    /**
     * 新增年度学校录取情况
     * 
     * @param schoolYearAdmission 年度学校录取情况
     * @return 结果
     */
    @Override
    public int insertSchoolYearAdmission(SchoolYearAdmission schoolYearAdmission)
    {
        return schoolYearAdmissionMapper.insertSchoolYearAdmission(schoolYearAdmission);
    }

    /**
     * 修改年度学校录取情况
     * 
     * @param schoolYearAdmission 年度学校录取情况
     * @return 结果
     */
    @Override
    public int updateSchoolYearAdmission(SchoolYearAdmission schoolYearAdmission)
    {
        return schoolYearAdmissionMapper.updateSchoolYearAdmission(schoolYearAdmission);
    }

    /**
     * 批量删除年度学校录取情况
     * 
     * @param ids 需要删除的年度学校录取情况主键
     * @return 结果
     */
    @Override
    public int deleteSchoolYearAdmissionByIds(Long[] ids)
    {
        return schoolYearAdmissionMapper.deleteSchoolYearAdmissionByIds(ids);
    }

    /**
     * 删除年度学校录取情况信息
     * 
     * @param id 年度学校录取情况主键
     * @return 结果
     */
    @Override
    public int deleteSchoolYearAdmissionById(Long id)
    {
        return schoolYearAdmissionMapper.deleteSchoolYearAdmissionById(id);
    }
    
    @Override
	public String impGradeDoc(String filePath,String dataType) {
		//String fileName= "D:\\001.xls"; 
		String fileName= filePath; 
		File file = new File(fileName);
		
	    try {
	    	List<Object[]> list = new ArrayList<>();
	    	
	    	InputStream inputStream = new FileInputStream(fileName);
            Workbook workbook = WorkbookFactory.create(inputStream);
            Sheet sheet = workbook.getSheetAt(0);
            String sheetName=sheet.getSheetName();
            String yearStr=sheetName.substring(0, 4);
            String gradeClass=sheetName.substring(5, 7);
            String useIn="广西";
            if(sheetName.indexOf("国")>-1) {
            	useIn="全国";
            }
            
          //获取sheet的行数
            int rows = sheet.getLastRowNum();
            for (int i = 0; i <= rows; i++) {
            	//获取当前行的数据
                Row row = sheet.getRow(i);
                if(row!=null) {
	                Object[] objects = new Object[row.getLastCellNum()];
	                int index = 0;
	                for (int j=0;j< row.getLastCellNum();j++) {
	                	Cell cell=row.getCell(j);
	                	if(cell==null) {
	                		objects[index] = "";
	                	}else {
		                	if (cell.getCellType().equals(CellType.NUMERIC)) {
		                		int num=(int) cell.getNumericCellValue();
		                        objects[index] = new Integer(num).toString();
		                    }else {
		                    	objects[index] = cell.getStringCellValue();
		                    }
	                	}
	                	/*
	                	if (cell.getCellType().equals(CellType.STRING)) {
	                		objects[index] = cell.getStringCellValue();
	                	}
	                	*/
	                    
	                    index++;
	                }
	                list.add(objects);
                }
            }
            
            List<GkGradeDoc> gkGradeDocList=new ArrayList();
            
            for(int i=1;i<list.size();i++) {
            	Object[] objArr=list.get(i);
            	String gradeStr=(String)objArr[0];
            	String peopleStr=(String)objArr[1];
            	String totalPeopleStr=(String)objArr[2];
            	String seqStr=(String)objArr[3];
            	
            	GkGradeDoc gkGradeDoc=new GkGradeDoc();
            	gkGradeDoc.setGrade(new Integer(gradeStr));
            	gkGradeDoc.setGradeClass(gradeClass);
            	gkGradeDoc.setPeople(new Integer(peopleStr));
            	gkGradeDoc.setSeq(new Integer(seqStr));
            	gkGradeDoc.setTotalPeople(new Integer(totalPeopleStr));
            	gkGradeDoc.setYear(new Integer(yearStr));
            	gkGradeDoc.setUseIn(useIn);
            	gkGradeDocList.add(gkGradeDoc);
            }
            /*
            if(workbook.getNumberOfSheets()>1) {
	            sheet = workbook.getSheetAt(1);
	            sheetName=sheet.getSheetName();
	            yearStr=sheetName.substring(0, 4);
	            gradeClass=sheetName.substring(5, 7);
	            
	            list = new ArrayList<>();
	            
	            //获取sheet的行数
	            rows = sheet.getPhysicalNumberOfRows();
	            for (int i = 0; i < rows; i++) {
	            	//获取当前行的数据
	                Row row = sheet.getRow(i);
	                if(row!=null) {
		                Object[] objects = new Object[row.getPhysicalNumberOfCells()];
		                int index = 0;
		                for (Cell cell : row) {
		                	
		                	if (cell.getCellType().equals(CellType.NUMERIC)) {
		                		int num=(int) cell.getNumericCellValue();
		                        objects[index] = new Integer(num).toString();
		                    }
		                	
		                	if (cell.getCellType().equals(CellType.STRING)) {
		                		objects[index] = cell.getStringCellValue();
		                	}
		                    
		                    index++;
		                }
		                list.add(objects);
	                }
	            }
            }
            
            
            for(int i=1;i<list.size();i++) {
            	Object[] objArr=list.get(i);
            	String gradeStr=(String)objArr[0];
            	String peopleStr=(String)objArr[1];
            	String totalPeopleStr=(String)objArr[2];
            	String seqStr=(String)objArr[3];
            	
            	GkGradeDoc gkGradeDoc=new GkGradeDoc();
            	gkGradeDoc.setGrade(new Integer(gradeStr));
            	gkGradeDoc.setGradeClass(gradeClass);
            	gkGradeDoc.setPeople(new Integer(peopleStr));
            	gkGradeDoc.setSeq(new Integer(seqStr));
            	gkGradeDoc.setTotalPeople(new Integer(totalPeopleStr));
            	gkGradeDoc.setYear(new Integer(yearStr));
            	gkGradeDoc.setUseIn(useIn);
            	gkGradeDocList.add(gkGradeDoc);
            }
            */
            gkGradeDocMapper.insertGkGradeDocList(gkGradeDocList);
            
	    } catch (IOException e) {
	        e.printStackTrace();
	        throw new RuntimeException("导入失败");
	    } finally {
	        
	    }
	    return "成功";
    }
    
    public static boolean startsWithDigit(String str) {
        return str.matches("^\\d+.*");
    }
    
    @Override
    //@Transactional
	public String impPlan(String filePath,String dataType) {
		//String fileName= "D:\\00173.xls"; 
		String fileName= filePath; 
		File file = new File(fileName);
		
	    try {
	    	List<Object[]> list = new ArrayList<>();
	    	
	    	InputStream inputStream = new FileInputStream(fileName);
            Workbook workbook = WorkbookFactory.create(inputStream);
            Sheet sheet = workbook.getSheetAt(0);
            String sheetName=sheet.getSheetName();
            if(sheetName.length()<4) {
            	return "年份未填写。";
            }
            String yearStr=sheetName.substring(0, 4);
            //String gradeClass=sheetName.substring(5, 7);
            
            School school=new School();
            List<School> schoolList=schoolMapper.selectSchoolList(school);
            
          //取出数据库所有的专业
            List<SMajors> majorList=majorsMapper.selectSMajorsList(null);
            
            
            boolean errorFlag=false;
            StringBuffer errorSb=new StringBuffer();
            
            //获取sheet的行数
          //获取sheet的行数
            int rows = sheet.getLastRowNum();
            for (int i = 0; i <= rows; i++) {
            	//获取当前行的数据
                Row row = sheet.getRow(i);
                if(row!=null) {
	                Object[] objects = new Object[row.getLastCellNum()];
	                int index = 0;
	                for (int j=0;j< row.getLastCellNum();j++) {
	                	Cell cell=row.getCell(j);
	                	if(cell==null) {
	                		objects[index] = "";
	                	}else {
		                	if (cell.getCellType().equals(CellType.NUMERIC)) {
		                		int num=(int) cell.getNumericCellValue();
		                        objects[index] = new Integer(num).toString();
		                    }else {
		                    	objects[index] = cell.getStringCellValue();
		                    }
	                	}
	                	/*
	                	if (cell.getCellType().equals(CellType.STRING)) {
	                		objects[index] = cell.getStringCellValue();
	                	}
	                	*/
	                    
	                    index++;
	                }
	                list.add(objects);
                }
            }

            
            String lastSchoolCode="";
            String lastSchoolName="";
            Integer lastSchoolPlan=0;
            Integer lastMajorLgPlan=0;
            Integer lastMajorWsPlan=0;
            String batch="";
            
            List<SchoolPlan> schoolPlanList=new ArrayList();
            
            for(int i=0;i<list.size();i++) {
            	Object[] objArr=list.get(i);
            	String str=(String)objArr[0];
            	if(str!=null) {
            		if(startsWithDigit(str)) {//这行内容以数字开头
            			
            			
            			boolean isSchool=false;
            			String[] strArr=str.split(" ");
            			for(int j=0;j<schoolList.size();j++) {
            				School schoolObj=schoolList.get(j);
            				try {
	            				if(strArr[0].equals(schoolObj.getScode())) {//如果数字=学校编号，这行是学校招生人数
	            					lastSchoolCode=strArr[0];
	            					lastSchoolName=schoolObj.getSname();
	            					String planRen=strArr[2];
	            					StringBuilder number = new StringBuilder();
	            			        for (char c : planRen.toCharArray()) {
	            			            if (Character.isDigit(c)) {
	            			                number.append(c);
	            			            }
	            			        }
	            			        if (number.length() > 0) {
	            			        	lastSchoolPlan=new Integer(number.toString());
	            			        	
	            			        	lastMajorLgPlan=0;
	            			        	lastMajorWsPlan=0;
	            			        }
	            			        
	            			        //统计文史类、理工类
	            			        if(str.indexOf("（理")>0) {
	            			        	String str2=str.substring(str.indexOf("（理"), str.length());
	            			        	if(str2.indexOf("文")>0&&str2.indexOf("文")>str2.indexOf("（理")) {//有文史类
	            			        		String lgStr=str2.substring(str2.indexOf("（理")+2, str2.indexOf("文"));
	    	            			        lgStr=lgStr.trim();
	    	            			        StringBuilder lgNumber = new StringBuilder();
	    	            			        for (char c : lgStr.toCharArray()) {
	    	            			            if (Character.isDigit(c)) {
	    	            			            	lgNumber.append(c);
	    	            			            }
	    	            			        }
	    	            			        if (lgNumber.length() > 0) {
	    	            			        	lastMajorLgPlan=new Integer(lgNumber.toString());
	    	            			        }
	    	            			        
	    	            			        if(str2.indexOf("）")>0) {
	    	            			        	if(str2.indexOf("）")>str2.indexOf("文")) {
	    	            			        		String wsStr=str2.substring(str2.indexOf("文")+1, str2.indexOf("）"));
	    	            			        		wsStr=wsStr.trim();
	    	            			        		StringBuilder wsNumber = new StringBuilder();
	    	    	            			        for (char c : wsStr.toCharArray()) {
	    	    	            			            if (Character.isDigit(c)) {
	    	    	            			            	wsNumber.append(c);
	    	    	            			            }
	    	    	            			        }
	    	    	            			        if (wsNumber.length() > 0) {
	    	    	            			        	lastMajorWsPlan=new Integer(wsNumber.toString());
	    	    	            			        }
	    	            			        	}
	    	            			        }else if(str2.indexOf(")")>0) {
	    	            			        	if(str2.indexOf("）")>str2.indexOf("文")) {
	    	            			        		String wsStr=str2.substring(str2.indexOf("文")+1, str2.indexOf(")"));
	    	            			        		wsStr=wsStr.trim();
	    	            			        		StringBuilder wsNumber = new StringBuilder();
	    	    	            			        for (char c : wsStr.toCharArray()) {
	    	    	            			            if (Character.isDigit(c)) {
	    	    	            			            	wsNumber.append(c);
	    	    	            			            }
	    	    	            			        }
	    	    	            			        if (wsNumber.length() > 0) {
	    	    	            			        	lastMajorWsPlan=new Integer(wsNumber.toString());
	    	    	            			        }
	    	            			        	}
	    	            			        }
	            			        	}else {//只有理工，没有文史类
	            			        		if(str2.indexOf("）")>0&&str2.indexOf("）")>0&&str2.indexOf("（理")>-1) {
	            			        			String lgStr=str2.substring(str2.indexOf("（理")+2, str2.indexOf("）"));
		    	            			        lgStr=lgStr.trim();
		    	            			        StringBuilder lgNumber = new StringBuilder();
		    	            			        for (char c : lgStr.toCharArray()) {
		    	            			            if (Character.isDigit(c)) {
		    	            			            	lgNumber.append(c);
		    	            			            }
		    	            			        }
		    	            			        if (lgNumber.length() > 0) {
		    	            			        	lastMajorLgPlan=new Integer(lgNumber.toString());
		    	            			        }
	            			        		}else if(str2.indexOf(")")>0&&str2.indexOf(")")>0&&str2.indexOf("（理")>-1) {
	            			        			String lgStr=str2.substring(str2.indexOf("（理")+2, str2.indexOf(")"));
		    	            			        lgStr=lgStr.trim();
		    	            			        StringBuilder lgNumber = new StringBuilder();
		    	            			        for (char c : lgStr.toCharArray()) {
		    	            			            if (Character.isDigit(c)) {
		    	            			            	lgNumber.append(c);
		    	            			            }
		    	            			        }
		    	            			        if (lgNumber.length() > 0) {
		    	            			        	lastMajorLgPlan=new Integer(lgNumber.toString());
		    	            			        }
	            			        		}
	            			        	}
	            			        }else if(str.indexOf("（文")>0) {//只有文史类，没有理工类
	            			        	String str2=str.substring(str.indexOf("（文"), str.length());
	            			        	if(str2.indexOf("）")>0&&str2.indexOf("）")>0&&str2.indexOf("（文")>-1) {
            			        			String lgStr=str2.substring(str2.indexOf("（文")+2, str2.indexOf("）"));
	    	            			        lgStr=lgStr.trim();
	    	            			        StringBuilder lgNumber = new StringBuilder();
	    	            			        for (char c : lgStr.toCharArray()) {
	    	            			            if (Character.isDigit(c)) {
	    	            			            	lgNumber.append(c);
	    	            			            }
	    	            			        }
	    	            			        if (lgNumber.length() > 0) {
	    	            			        	lastMajorWsPlan=new Integer(lgNumber.toString());
	    	            			        }
            			        		}else if(str2.indexOf(")")>0&&str2.indexOf(")")>0&&str2.indexOf("（文")>-1) {
            			        			String lgStr=str2.substring(str2.indexOf("（文")+2, str2.indexOf(")"));
	    	            			        lgStr=lgStr.trim();
	    	            			        StringBuilder lgNumber = new StringBuilder();
	    	            			        for (char c : lgStr.toCharArray()) {
	    	            			            if (Character.isDigit(c)) {
	    	            			            	lgNumber.append(c);
	    	            			            }
	    	            			        }
	    	            			        if (lgNumber.length() > 0) {
	    	            			        	lastMajorWsPlan=new Integer(lgNumber.toString());
	    	            			        }
            			        		}
	            			        }else {
	            			        	errorFlag=false;
	            			            errorSb=new StringBuffer("第"+i+"行数据"+str+"没有理工类、文史类招生计划");
	            			        }
	            			        
	            			        
	            					isSchool=true;
	            					break;
	            				}
            				}catch(Exception e3) {
            					System.out.println("第"+i+"行数据"+strArr[0]+strArr[1]+"错误。");
            					errorFlag=true;
    							errorSb.append("第"+i+"行数据"+strArr[0]+strArr[1]+"错误。<br/>");
    							
            					e3.printStackTrace();
            					continue;
            				}
            			}
            			
            			if(isSchool) {//说明这行是学校信息
            				
            			}else {//这行不是学校信息，应该是专业信息了
            				
            				//判断数字是否3位数字
            				StringBuilder number2 = new StringBuilder();
            				for (char c : strArr[0].toCharArray()) {
        			            if (Character.isDigit(c)) {
        			                number2.append(c);
        			            }
        			        }
        			        if (number2.length() != 3) {//专业序号不是3位数字，跳过
        			        	continue;
        			        }
        			        
        			        
        			        
        			        
            				
            				SchoolPlan schoolPlan=new SchoolPlan();
            				schoolPlan.setSchoolCode(lastSchoolCode);
            				schoolPlan.setSchoolName(lastSchoolName);
            				schoolPlan.setSchoolPlan(lastSchoolPlan);
            				schoolPlan.setYear(new Integer(yearStr));
            				
            				schoolPlan.setBatch(batch);
            				
            				schoolPlan.setMajorSeq(strArr[0]);
            				schoolPlan.setMajorLgPlan(lastMajorLgPlan);
            				schoolPlan.setMajorWsPlan(lastMajorWsPlan);
            				
            				schoolPlan.setCreateTime(new Date());
            				
            				if(strArr[1].indexOf("，")>-1) {
            					strArr[1]=strArr[1].replaceAll("，", ",");
        					}
            				if(strArr[1].indexOf("（")>-1) {
            					strArr[1]=strArr[1].replaceAll("（", "(");
        					}
            				if(strArr[1].indexOf("）")>-1) {
            					strArr[1]=strArr[1].replaceAll("）", ")");
        					}
            				
            				try {
            					schoolPlan.setMajorName(strArr[1]);
            					String mCode="";
            					boolean majorFlag=false;//专业名相同标志
		            			boolean majorKHFlag=false;//专业括号名相同标志
		            			int sameMajor=0;
		            			
            					for(int k=0;k<majorList.size();k++) {
            						SMajors sMajors=majorList.get(k);
            						if(sMajors.getMname().equals(strArr[1])) {
            							mCode=sMajors.getMcode();
            							schoolPlan.setMajorCode(mCode);
            							majorFlag=true;
            							break;
            						}
            					}
            					if(!majorFlag) {//如果专业不存在，需要插入专业表
            						if(strArr[1].indexOf("（")>-1) {//判断是否包含中文括号
			            				String major1=strArr[1].substring(0, strArr[1].indexOf("（"));//去掉括号后的专业名称
			            				String major2=strArr[1].substring( strArr[1].indexOf("（")+1,strArr[1].length());
			            				
			            				for(int m=0;m<majorList.size();m++) {
				            				SMajors majorObj2=majorList.get(m);
				            				String name2=majorObj2.getMname();
				            				if(name2.indexOf("(")>-1) {
				            					name2=name2.replaceAll("\\(", "（");
				            				}
				            				if(name2.indexOf(")")>-1) {
				            					name2=name2.replaceAll("\\)", "）");
				            				}
				            				if(name2.indexOf("，")>-1) {
				            					name2=name2.replaceAll("，", ",");
				            				}
				            				if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
				            					mCode=majorObj2.getMcode();
				            					//schoolPlan.setMajorCode(mCode);
				            					majorKHFlag=true;
				            					break;
				            				}
			            				}
			            				
			            				if(majorKHFlag) {//去掉括号后的专业名称存在，按序号增加
			            					
			            					for(int m=0;m<majorList.size();m++) {
					            				SMajors majorObj2=majorList.get(m);
					            				if(majorObj2.getMname().indexOf("（")>-1) {
					            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
						            				if(major3.equals(major1)) {
						            					sameMajor++;
						            				}
					            				}else if(majorObj2.getMname().indexOf("(")>-1) {
					            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
						            				if(major3.equals(major1)) {
						            					sameMajor++;
						            				}
					            				}else {
					            					if(majorObj2.getMname().equals(major1)) {
						            					sameMajor++;
						            				}
					            				}
					            				
			            					}
			            					String code="";
			            					sameMajor++;
			            					if(sameMajor>9) {
			            						code=new Integer(sameMajor).toString();
			            					}else {
			            						code="0"+sameMajor;
			            					}
			            					SMajors sMajors=new SMajors();
			            					sMajors.setMname(strArr[1]);
			            					if(mCode!=null) {
			            						if(sMajors.getMname().indexOf("类")>-1) {
			            							sMajors.setMcode(mCode+"0"+code);
				            						schoolPlan.setMajorCode(mCode+"0"+code);
			            						}else {
			            							sMajors.setMcode(mCode+code);
				            						schoolPlan.setMajorCode(mCode+code);
			            						}
			            						
			            					}else {
			            						sMajors.setMcode(code);
			            						schoolPlan.setMajorCode(code);
			            					}
			            					sMajors.setCreateTime(new Date());
				            				majorsMapper.insertSMajors(sMajors);
				            				
				            				majorList.add(sMajors);
				            				
				            				
			            				}
            						}else if(strArr[1].indexOf("(")>-1) {//判断是否包含英文括号
			            				String major1=strArr[1].substring(0, strArr[1].indexOf("("));
			            				String major2=strArr[1].substring( strArr[1].indexOf("(")+1,strArr[1].length());
			            				
			            				for(int m=0;m<majorList.size();m++) {
				            				SMajors majorObj2=majorList.get(m);
				            				String name2=majorObj2.getMname();
				            				if(name2.indexOf("（")>-1) {
				            					name2=name2.replaceAll("（", "(");
				            				}
				            				if(name2.indexOf("）")>-1) {
				            					name2=name2.replaceAll("）", ")");
				            				}
				            				if(name2.indexOf("，")>-1) {
				            					name2=name2.replaceAll("，", ",");
				            				}
				            				if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
				            					mCode=majorObj2.getMcode();
				            					//schoolPlan.setMajorCode(mCode);
				            					majorKHFlag=true;
				            					break;
				            				}
			            				}
			            				
			            				if(majorKHFlag) {//去掉括号后的专业名称存在，按序号增加
			            					
			            					for(int m=0;m<majorList.size();m++) {
					            				SMajors majorObj2=majorList.get(m);
					            				if(majorObj2.getMname().indexOf("（")>-1) {
					            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
						            				if(major3.equals(major1)) {
						            					sameMajor++;
						            				}
					            				}else if(majorObj2.getMname().indexOf("(")>-1) {
					            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
						            				if(major3.equals(major1)) {
						            					sameMajor++;
						            				}
					            				}else {
					            					if(majorObj2.getMname().equals(major1)) {
						            					sameMajor++;
						            				}
					            				}
					            				
			            					}
			            					String code="";
			            					sameMajor++;
			            					if(sameMajor>9) {
			            						code=new Integer(sameMajor).toString();
			            					}else {
			            						code="0"+sameMajor;
			            					}
			            					SMajors sMajors=new SMajors();
			            					
			            					sMajors.setMname(strArr[1]);
			            					if(mCode!=null) {
			            						if(sMajors.getMname().indexOf("类")>-1) {
			            							sMajors.setMcode(mCode+"0"+code);
				            						schoolPlan.setMajorCode(mCode+"0"+code);
			            						}else {
			            							sMajors.setMcode(mCode+code);
				            						schoolPlan.setMajorCode(mCode+code);
			            						}
			            					}else {
			            						sMajors.setMcode(code);
			            						schoolPlan.setMajorCode(code);
			            					}
			            					sMajors.setCreateTime(new Date());
				            				majorsMapper.insertSMajors(sMajors);
				            				
				            				majorList.add(sMajors);
				            				
				            				
			            				}
            						}else {//去掉括号后，专业名称也不存在，则需要增加这个新的专业
            							System.out.println("-------strArr=--------"+strArr[1]);
                    					//return  "第"+(i+1)+"行数据"+strArr[1]+"专业没有编码。";
            							errorFlag=true;
            							errorSb.append("第"+(i+1)+"行数据"+strArr[1]+"专业没有编码。<br/>");
            							continue;
			            			}
            					}
            					
            					
            				}catch(Exception ee) {
            					System.out.println("-------strArr=--------"+strArr[1]);
            					//return  "第"+(i+1)+"行数据"+strArr[1]+"专业有误。错误信息："+ee.getMessage();
            					errorFlag=true;
    							errorSb.append("第"+(i+1)+"行数据"+strArr[1]+"专业有误。错误信息："+ee.getMessage()+"<br/>");
    							continue;
            				}
            				try {
	            				String planRen=strArr[2];
	        					StringBuilder number = new StringBuilder();
	        			        for (char c : planRen.toCharArray()) {
	        			            if (Character.isDigit(c)) {
	        			                number.append(c);
	        			            }
	        			        }
	        			        if (number.length() > 0) {
	        			        	schoolPlan.setMajorPlan(new Integer(number.toString()));
	        			        }else {
	        			        	System.out.println("-------strArr=--------"+strArr[1]+strArr[2]);
	            					//return  "第"+(i+1)+"行数据"+strArr[1]+strArr[2]+"招生人数有误。";
	            					errorFlag=true;
	    							errorSb.append("第"+(i+1)+"行数据"+strArr[1]+strArr[2]+"招生人数有误。"+"<br/>");
	    							continue;
	        			        }
            				}catch(Exception ee) {
            					System.out.println("-------strArr=--------"+strArr[1]);
            					//return  "第"+(i+1)+"行数据"+strArr[1]+strArr[2]+"招生人数有误。错误信息："+ee.getMessage();
            					errorFlag=true;
    							errorSb.append("第"+(i+1)+"行数据"+strArr[1]+"招生人数有误。错误信息："+ee.getMessage()+"<br/>");
    							continue;
            				}
            				
            				String majorType="";
            				
            				if(strArr.length>2) {
	            				if(strArr[2].indexOf("理工类")>-1) {
	            					majorType="理工类";
	            				}else if(strArr[2].indexOf("文史类")>-1) {
	            					majorType="文史类";
	            				}
            				}            				
            				if(strArr.length>3) {
	            				if(strArr[3].indexOf("理工类")>-1) {
	            					majorType="理工类";
	            				}else if(strArr[3].indexOf("文史类")>-1) {
	            					majorType="文史类";
	            				}
            				}
            				if(strArr.length>4) {
	            				if(strArr[4].indexOf("理工类")>-1) {
	            					majorType="理工类";
	            				}else if(strArr[4].indexOf("文史类")>-1) {
	            					majorType="文史类";
	            				}
            				}
            				
            				if("".equals(majorType)) {
            					System.out.println("-------strArr=--------"+strArr[1]+strArr[2]+"专业分类有误");
            					//return  "第"+(i+1)+"行数据"+strArr[1]+strArr[2]+"获取不到专业分类。";
            					
            					errorFlag=true;
    							errorSb.append("第"+(i+1)+"行数据"+strArr[1]+strArr[2]+"获取不到专业分类。"+"<br/>");
    							continue;
            				}else {
            					schoolPlan.setMajorType(majorType);
            				}
            				
            				
            				
            				SchoolPlan schoolPlanQuery=new SchoolPlan();
        			        schoolPlanQuery.setSchoolCode(schoolPlan.getSchoolCode());
        			        schoolPlanQuery.setYear(schoolPlan.getYear());            				
        			        schoolPlanQuery.setBatch(schoolPlan.getBatch());
        			        schoolPlanQuery.setMajorCode(schoolPlan.getMajorCode());
        			        schoolPlanQuery.setMajorType(schoolPlan.getMajorType());
            				
        			        List<SchoolPlan> list2=schoolPlanMapper.selectSchoolPlanList(schoolPlanQuery);
        			        if(list2!=null&&list2.size()>0) {
        			        	schoolPlanMapper.deleteSchoolPlanByScodeYearBatch(schoolPlanQuery);
        			        }

            				schoolPlanList.add(schoolPlan);
            				
            				
            			}
            		}else {
            			if(str.indexOf("本科第一批预科")>-1) {
            				batch="本科第一批预科";
            			}else if(str.indexOf("本科第一批")>-1) {
            				batch="本科第一批";
            			}else if(str.indexOf("本科第二批预科")>-1) {
            				if(str.indexOf("A")>-1) {
            					batch="本科第二批预科A类";
            				}else if(str.indexOf("B")>-1) {
            					batch="本科第二批预科B类";
            				}            				
            			}else if(str.indexOf("本科第二批")>-1) {
            				batch="本科第二批";
            			}
            		}
            	}
            	
            	
            }
            
            if(errorFlag) {
            	return errorSb.toString();
            }
            
            if(schoolPlanList.size()>0) {
	            List<SchoolPlan> insertSchoolPlanList=new ArrayList();
	            int k=0;
	            for(int i=0;i<schoolPlanList.size();i++) {
	            	SchoolPlan plan=schoolPlanList.get(i);
	            	insertSchoolPlanList.add(plan);
	            	k++;
	            	if(k>500) {
	            		schoolPlanMapper.insertSchoolPlanList(insertSchoolPlanList);
	            		insertSchoolPlanList=new ArrayList();
	            		k=0;
	            	}
	            }
	            if(insertSchoolPlanList.size()>0) {
	            	schoolPlanMapper.insertSchoolPlanList(insertSchoolPlanList);
	            }
            }
            
            
            SchoolPlan schoolPlanQuery=new SchoolPlan();
            schoolPlanQuery.setBatch(batch);
            schoolPlanQuery.setYear(new Integer(yearStr));
            schoolPlanQuery.setMajorType("理工类");
            List<SchoolPlan> lgList=schoolPlanMapper.selectSchoolPlanSumList(schoolPlanQuery);
            List<SchoolPlan> updateSchoolPlanList=new ArrayList();
            if(lgList!=null&&lgList.size()>0) {
            	int k=0;
            	for(int i=0;i<lgList.size();i++) {
            		SchoolPlan lg=lgList.get(i);
            		lg.setMajorLgPlan(lg.getMajorPlan());
            		updateSchoolPlanList.add(lg);
            		k++;
            		if(k>500) {
            			schoolPlanMapper.updateSchoolPlanLgList(updateSchoolPlanList);
            			updateSchoolPlanList=new ArrayList();
            			k=0;
            		}
            	}
            	if(updateSchoolPlanList.size()>0) {
            		schoolPlanMapper.updateSchoolPlanLgList(updateSchoolPlanList);
            	}
            }
            
            schoolPlanQuery=new SchoolPlan();
            schoolPlanQuery.setBatch(batch);
            schoolPlanQuery.setYear(new Integer(yearStr));
            schoolPlanQuery.setMajorType("文史类");
            List<SchoolPlan> wsList=schoolPlanMapper.selectSchoolPlanSumList(schoolPlanQuery);
            if(wsList!=null&&wsList.size()>0) {
            	updateSchoolPlanList=new ArrayList();
            	int k=0;
            	for(int i=0;i<wsList.size();i++) {
            		SchoolPlan ws=wsList.get(i);
            		ws.setMajorWsPlan(ws.getMajorPlan());
            		updateSchoolPlanList.add(ws);
            		k++;
            		if(k>500) {
            			schoolPlanMapper.updateSchoolPlanWsList(updateSchoolPlanList);
            			updateSchoolPlanList=new ArrayList();
            			k=0;
            		}
            	}
            	if(updateSchoolPlanList.size()>0) {
            		schoolPlanMapper.updateSchoolPlanWsList(updateSchoolPlanList);
            	}
            }
            
            
	    } catch (IOException e) {
	        e.printStackTrace();
	        throw new RuntimeException("导入失败");
	    } finally {
	        
	    }
	    return "成功";
    }
    
    
    
    @Override
    //@Transactional
	public String impPlanZk(String filePath,String dataType) {
		//String fileName= "D:\\物理456-581.xls"; 
		String fileName= filePath; 
		File file = new File(fileName);
		
	    try {
	    	List<Object[]> list = new ArrayList<>();
	    	
	    	InputStream inputStream = new FileInputStream(fileName);
            Workbook workbook = WorkbookFactory.create(inputStream);
            Sheet sheet = workbook.getSheetAt(0);
            String sheetName=sheet.getSheetName();
            if(sheetName.length()<4) {
            	return "年份未填写。";
            }
            String yearStr=sheetName.substring(0, 4);
            //String gradeClass=sheetName.substring(5, 7);
            
            School school=new School();
            List<School> schoolList=schoolMapper.selectSchoolList(school);
            
          //取出数据库所有的专业
            List<SMajors> majorList=majorsMapper.selectSMajorsList(null);
            
            
            boolean errorFlag=false;
            StringBuffer errorSb=new StringBuffer();
            
            //获取sheet的行数
          //获取sheet的行数
            int rows = sheet.getLastRowNum();
            for (int i = 0; i < rows; i++) {
            	//获取当前行的数据
                Row row = sheet.getRow(i);
                if(row!=null) {
	                Object[] objects = new Object[1];
	                int index = 0;
	                for (int j=0;j< 1;j++) {
	                	Cell cell=row.getCell(j);
	                	if(cell==null) {
	                		objects[index] = "";
	                	}else {
		                	if (cell.getCellType().equals(CellType.NUMERIC)) {
		                		int num=(int) cell.getNumericCellValue();
		                        objects[index] = new Integer(num).toString();
		                    }else {
		                    	objects[index] = cell.getStringCellValue();
		                    }
	                	}
	                	/*
	                	if (cell.getCellType().equals(CellType.STRING)) {
	                		objects[index] = cell.getStringCellValue();
	                	}
	                	*/
	                    
	                    index++;
	                }
	                list.add(objects);
                }
            }

            
            String lastSchoolCode="";
            String lastSchoolName="";
            Integer lastSchoolPlan=0;
            Integer lastMajorLgPlan=0;
            Integer lastMajorWsPlan=0;
            String batch="";
            
            List<SchoolPlan> schoolPlanList=new ArrayList();
            
            for(int i=0;i<list.size();i++) {
            	Object[] objArr=list.get(i);
            	String str=(String)objArr[0];
            	if(str!=null) {
            		if(startsWithDigit(str)) {//这行内容以数字开头
            			
            			
            			boolean isSchool=false;
            			String[] strArr=str.split(" ");
            			for(int j=0;j<schoolList.size();j++) {
            				School schoolObj=schoolList.get(j);
            				try {
	            				if(strArr[0].equals(schoolObj.getScode())) {//如果数字=学校编号，这行是学校招生人数
	            					lastSchoolCode=strArr[0];
	            					lastSchoolName=schoolObj.getSname();
	            					String planRen=strArr[2];
	            					StringBuilder number = new StringBuilder();
	            			        for (char c : planRen.toCharArray()) {
	            			            if (Character.isDigit(c)) {
	            			                number.append(c);
	            			            }
	            			        }
	            			        if (number.length() > 0) {
	            			        	lastSchoolPlan=new Integer(number.toString());
	            			        	
	            			        	lastMajorLgPlan=0;
	            			        	lastMajorWsPlan=0;
	            			        }
	            			        
	            			        //统计文史类、理工类
	            			        if(str.indexOf("（理")>0) {
	            			        	String str2=str.substring(str.indexOf("（理"), str.length());
	            			        	if(str2.indexOf("文")>0&&str2.indexOf("文")>str2.indexOf("（理")) {//有文史类
	            			        		String lgStr=str2.substring(str2.indexOf("（理")+2, str2.indexOf("文"));
	    	            			        lgStr=lgStr.trim();
	    	            			        StringBuilder lgNumber = new StringBuilder();
	    	            			        for (char c : lgStr.toCharArray()) {
	    	            			            if (Character.isDigit(c)) {
	    	            			            	lgNumber.append(c);
	    	            			            }
	    	            			        }
	    	            			        if (lgNumber.length() > 0) {
	    	            			        	lastMajorLgPlan=new Integer(lgNumber.toString());
	    	            			        }
	    	            			        
	    	            			        if(str2.indexOf("）")>0) {
	    	            			        	if(str2.indexOf("）")>str2.indexOf("文")) {
	    	            			        		String wsStr=str2.substring(str2.indexOf("文")+1, str2.indexOf("）"));
	    	            			        		wsStr=wsStr.trim();
	    	            			        		StringBuilder wsNumber = new StringBuilder();
	    	    	            			        for (char c : wsStr.toCharArray()) {
	    	    	            			            if (Character.isDigit(c)) {
	    	    	            			            	wsNumber.append(c);
	    	    	            			            }
	    	    	            			        }
	    	    	            			        if (wsNumber.length() > 0) {
	    	    	            			        	lastMajorWsPlan=new Integer(wsNumber.toString());
	    	    	            			        }
	    	            			        	}
	    	            			        }else if(str2.indexOf(")")>0) {
	    	            			        	if(str2.indexOf("）")>str2.indexOf("文")) {
	    	            			        		String wsStr=str2.substring(str2.indexOf("文")+1, str2.indexOf(")"));
	    	            			        		wsStr=wsStr.trim();
	    	            			        		StringBuilder wsNumber = new StringBuilder();
	    	    	            			        for (char c : wsStr.toCharArray()) {
	    	    	            			            if (Character.isDigit(c)) {
	    	    	            			            	wsNumber.append(c);
	    	    	            			            }
	    	    	            			        }
	    	    	            			        if (wsNumber.length() > 0) {
	    	    	            			        	lastMajorWsPlan=new Integer(wsNumber.toString());
	    	    	            			        }
	    	            			        	}
	    	            			        }
	            			        	}else {//只有理工，没有文史类
	            			        		if(str2.indexOf("）")>0&&str2.indexOf("）")>0&&str2.indexOf("（理")>-1) {
	            			        			String lgStr=str2.substring(str2.indexOf("（理")+2, str2.indexOf("）"));
		    	            			        lgStr=lgStr.trim();
		    	            			        StringBuilder lgNumber = new StringBuilder();
		    	            			        for (char c : lgStr.toCharArray()) {
		    	            			            if (Character.isDigit(c)) {
		    	            			            	lgNumber.append(c);
		    	            			            }
		    	            			        }
		    	            			        if (lgNumber.length() > 0) {
		    	            			        	lastMajorLgPlan=new Integer(lgNumber.toString());
		    	            			        }
	            			        		}else if(str2.indexOf(")")>0&&str2.indexOf(")")>0&&str2.indexOf("（理")>-1) {
	            			        			String lgStr=str2.substring(str2.indexOf("（理")+2, str2.indexOf(")"));
		    	            			        lgStr=lgStr.trim();
		    	            			        StringBuilder lgNumber = new StringBuilder();
		    	            			        for (char c : lgStr.toCharArray()) {
		    	            			            if (Character.isDigit(c)) {
		    	            			            	lgNumber.append(c);
		    	            			            }
		    	            			        }
		    	            			        if (lgNumber.length() > 0) {
		    	            			        	lastMajorLgPlan=new Integer(lgNumber.toString());
		    	            			        }
	            			        		}
	            			        	}
	            			        }else if(str.indexOf("（文")>0) {//只有文史类，没有理工类
	            			        	String str2=str.substring(str.indexOf("（文"), str.length());
	            			        	if(str2.indexOf("）")>0&&str2.indexOf("）")>0&&str2.indexOf("（文")>-1) {
            			        			String lgStr=str2.substring(str2.indexOf("（文")+2, str2.indexOf("）"));
	    	            			        lgStr=lgStr.trim();
	    	            			        StringBuilder lgNumber = new StringBuilder();
	    	            			        for (char c : lgStr.toCharArray()) {
	    	            			            if (Character.isDigit(c)) {
	    	            			            	lgNumber.append(c);
	    	            			            }
	    	            			        }
	    	            			        if (lgNumber.length() > 0) {
	    	            			        	lastMajorWsPlan=new Integer(lgNumber.toString());
	    	            			        }
            			        		}else if(str2.indexOf(")")>0&&str2.indexOf(")")>0&&str2.indexOf("（文")>-1) {
            			        			String lgStr=str2.substring(str2.indexOf("（文")+2, str2.indexOf(")"));
	    	            			        lgStr=lgStr.trim();
	    	            			        StringBuilder lgNumber = new StringBuilder();
	    	            			        for (char c : lgStr.toCharArray()) {
	    	            			            if (Character.isDigit(c)) {
	    	            			            	lgNumber.append(c);
	    	            			            }
	    	            			        }
	    	            			        if (lgNumber.length() > 0) {
	    	            			        	lastMajorWsPlan=new Integer(lgNumber.toString());
	    	            			        }
            			        		}
	            			        }else {
	            			        	errorFlag=false;
	            			            errorSb=new StringBuffer("第"+i+"行数据"+str+"没有理工类、文史类招生计划");
	            			        }
	            			        
	            			        
	            					isSchool=true;
	            					break;
	            				}
            				}catch(Exception e3) {
            					System.out.println("第"+i+"行数据"+strArr[0]+strArr[1]+"错误。");
            					errorFlag=true;
    							errorSb.append("第"+i+"行数据"+strArr[0]+strArr[1]+"错误。<br/>");
    							
            					e3.printStackTrace();
            					continue;
            				}
            			}
            			
            			if(isSchool) {//说明这行是学校信息
            				
            			}else {//这行不是学校信息，应该是专业信息了
            				
            				//判断数字是否3位数字
            				StringBuilder number2 = new StringBuilder();
            				for (char c : strArr[0].toCharArray()) {
        			            if (Character.isDigit(c)) {
        			                number2.append(c);
        			            }
        			        }
        			        if (number2.length() != 3) {//专业序号不是3位数字，跳过
        			        	continue;
        			        }
        			        
        			        
        			        
        			        
            				
            				SchoolPlan schoolPlan=new SchoolPlan();
            				schoolPlan.setSchoolCode(lastSchoolCode);
            				schoolPlan.setSchoolName(lastSchoolName);
            				schoolPlan.setSchoolPlan(lastSchoolPlan);
            				schoolPlan.setYear(new Integer(yearStr));
            				
            				schoolPlan.setBatch(batch);
            				
            				schoolPlan.setMajorSeq(strArr[0]);
            				schoolPlan.setMajorLgPlan(lastMajorLgPlan);
            				schoolPlan.setMajorWsPlan(lastMajorWsPlan);
            				
            				schoolPlan.setCreateTime(new Date());
            				try {
	            				if(strArr.length>1&&  strArr[1].indexOf("，")>-1) {
	            					strArr[1]=strArr[1].replaceAll("，", ",");
	        					}
	            				if(strArr.length>1&& strArr[1].indexOf("（")>-1) {
	            					strArr[1]=strArr[1].replaceAll("（", "(");
	        					}
	            				if(strArr.length>1&& strArr[1].indexOf("）")>-1) {
	            					strArr[1]=strArr[1].replaceAll("）", ")");
	        					}
            				
            				
            					schoolPlan.setMajorName(strArr[1]);
            					String mCode="";
            					boolean majorFlag=false;//专业名相同标志
		            			boolean majorKHFlag=false;//专业括号名相同标志
		            			int sameMajor=0;
		            			
            					for(int k=0;k<majorList.size();k++) {
            						SMajors sMajors=majorList.get(k);
            						if(sMajors.getMname().equals(strArr[1])) {
            							mCode=sMajors.getMcode();
            							schoolPlan.setMajorCode(mCode);
            							majorFlag=true;
            							break;
            						}
            					}
            					if(!majorFlag) {//如果专业不存在，需要插入专业表
            						if(strArr[1].indexOf("（")>-1) {//判断是否包含中文括号
			            				String major1=strArr[1].substring(0, strArr[1].indexOf("（"));//去掉括号后的专业名称
			            				String major2=strArr[1].substring( strArr[1].indexOf("（")+1,strArr[1].length());
			            				
			            				for(int m=0;m<majorList.size();m++) {
				            				SMajors majorObj2=majorList.get(m);
				            				String name2=majorObj2.getMname();
				            				if(name2.indexOf("(")>-1) {
				            					name2=name2.replaceAll("\\(", "（");
				            				}
				            				if(name2.indexOf(")")>-1) {
				            					name2=name2.replaceAll("\\)", "）");
				            				}
				            				if(name2.indexOf("，")>-1) {
				            					name2=name2.replaceAll("，", ",");
				            				}
				            				if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
				            					mCode=majorObj2.getMcode();
				            					//schoolPlan.setMajorCode(mCode);
				            					majorKHFlag=true;
				            					break;
				            				}
			            				}
			            				
			            				if(majorKHFlag) {//去掉括号后的专业名称存在，按序号增加
			            					
			            					for(int m=0;m<majorList.size();m++) {
					            				SMajors majorObj2=majorList.get(m);
					            				if(majorObj2.getMname().indexOf("（")>-1) {
					            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
						            				if(major3.equals(major1)) {
						            					sameMajor++;
						            				}
					            				}else if(majorObj2.getMname().indexOf("(")>-1) {
					            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
						            				if(major3.equals(major1)) {
						            					sameMajor++;
						            				}
					            				}else {
					            					if(majorObj2.getMname().equals(major1)) {
						            					sameMajor++;
						            				}
					            				}
					            				
			            					}
			            					String code="";
			            					sameMajor++;
			            					if(sameMajor>9) {
			            						code=new Integer(sameMajor).toString();
			            					}else {
			            						code="0"+sameMajor;
			            					}
			            					SMajors sMajors=new SMajors();
			            					sMajors.setMname(strArr[1]);
			            					if(mCode!=null) {
			            						if(sMajors.getMname().indexOf("类")>-1) {
			            							sMajors.setMcode(mCode+"0"+code);
				            						schoolPlan.setMajorCode(mCode+"0"+code);
			            						}else {
			            							sMajors.setMcode(mCode+code);
				            						schoolPlan.setMajorCode(mCode+code);
			            						}
			            						
			            					}else {
			            						sMajors.setMcode(code);
			            						schoolPlan.setMajorCode(code);
			            					}
			            					sMajors.setCreateTime(new Date());
				            				majorsMapper.insertSMajors(sMajors);
				            				
				            				majorList.add(sMajors);
				            				
				            				
			            				}
            						}else if(strArr[1].indexOf("(")>-1) {//判断是否包含英文括号
			            				String major1=strArr[1].substring(0, strArr[1].indexOf("("));
			            				String major2=strArr[1].substring( strArr[1].indexOf("(")+1,strArr[1].length());
			            				
			            				for(int m=0;m<majorList.size();m++) {
				            				SMajors majorObj2=majorList.get(m);
				            				String name2=majorObj2.getMname();
				            				if(name2.indexOf("（")>-1) {
				            					name2=name2.replaceAll("（", "(");
				            				}
				            				if(name2.indexOf("）")>-1) {
				            					name2=name2.replaceAll("）", ")");
				            				}
				            				if(name2.indexOf("，")>-1) {
				            					name2=name2.replaceAll("，", ",");
				            				}
				            				if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
				            					mCode=majorObj2.getMcode();
				            					//schoolPlan.setMajorCode(mCode);
				            					majorKHFlag=true;
				            					break;
				            				}
			            				}
			            				
			            				if(majorKHFlag) {//去掉括号后的专业名称存在，按序号增加
			            					
			            					for(int m=0;m<majorList.size();m++) {
					            				SMajors majorObj2=majorList.get(m);
					            				if(majorObj2.getMname().indexOf("（")>-1) {
					            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
						            				if(major3.equals(major1)) {
						            					sameMajor++;
						            				}
					            				}else if(majorObj2.getMname().indexOf("(")>-1) {
					            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
						            				if(major3.equals(major1)) {
						            					sameMajor++;
						            				}
					            				}else {
					            					if(majorObj2.getMname().equals(major1)) {
						            					sameMajor++;
						            				}
					            				}
					            				
			            					}
			            					String code="";
			            					sameMajor++;
			            					if(sameMajor>9) {
			            						code=new Integer(sameMajor).toString();
			            					}else {
			            						code="0"+sameMajor;
			            					}
			            					SMajors sMajors=new SMajors();
			            					
			            					sMajors.setMname(strArr[1]);
			            					if(mCode!=null) {
			            						if(sMajors.getMname().indexOf("类")>-1) {
			            							sMajors.setMcode(mCode+"0"+code);
				            						schoolPlan.setMajorCode(mCode+"0"+code);
			            						}else {
			            							sMajors.setMcode(mCode+code);
				            						schoolPlan.setMajorCode(mCode+code);
			            						}
			            					}else {
			            						sMajors.setMcode(code);
			            						schoolPlan.setMajorCode(code);
			            					}
			            					sMajors.setCreateTime(new Date());
				            				majorsMapper.insertSMajors(sMajors);
				            				
				            				majorList.add(sMajors);
				            				
				            				
			            				}
            						}else {//去掉括号后，专业名称也不存在，则需要增加这个新的专业
            							System.out.println("-------strArr=--------"+strArr[1]);
                    					//return  "第"+(i+1)+"行数据"+strArr[1]+"专业没有编码。";
            							errorFlag=true;
            							errorSb.append("第"+(i+1)+"行数据"+strArr[1]+"专业没有编码。<br/>");
            							continue;
			            			}
            					}
            					
            					
            				}catch(Exception ee) {
            					System.out.println("-------strArr=--------"+strArr[1]);
            					//return  "第"+(i+1)+"行数据"+strArr[1]+"专业有误。错误信息："+ee.getMessage();
            					errorFlag=true;
    							errorSb.append("第"+(i+1)+"行数据"+strArr[1]+"专业有误。错误信息："+ee.getMessage()+"<br/>");
    							continue;
            				}
            				try {
	            				String planRen=strArr[2];
	        					StringBuilder number = new StringBuilder();
	        			        for (char c : planRen.toCharArray()) {
	        			            if (Character.isDigit(c)) {
	        			                number.append(c);
	        			            }
	        			        }
	        			        if (number.length() > 0) {
	        			        	schoolPlan.setMajorPlan(new Integer(number.toString()));
	        			        }else {
	        			        	System.out.println("-------strArr=--------"+strArr[1]+strArr[2]);
	            					//return  "第"+(i+1)+"行数据"+strArr[1]+strArr[2]+"招生人数有误。";
	            					errorFlag=true;
	    							errorSb.append("第"+(i+1)+"行数据"+strArr[1]+strArr[2]+"招生人数有误。"+"<br/>");
	    							continue;
	        			        }
            				}catch(Exception ee) {
            					System.out.println("-------strArr=--------"+strArr[1]);
            					//return  "第"+(i+1)+"行数据"+strArr[1]+strArr[2]+"招生人数有误。错误信息："+ee.getMessage();
            					errorFlag=true;
    							errorSb.append("第"+(i+1)+"行数据"+strArr[1]+"招生人数有误。错误信息："+ee.getMessage()+"<br/>");
    							continue;
            				}
            				
            				String majorType="";
            				
            				if(strArr.length>2) {
	            				if(strArr[2].indexOf("理工类")>-1) {
	            					majorType="理工类";
	            				}else if(strArr[2].indexOf("文史类")>-1) {
	            					majorType="文史类";
	            				}
            				}            				
            				if(strArr.length>3) {
	            				if(strArr[3].indexOf("理工类")>-1) {
	            					majorType="理工类";
	            				}else if(strArr[3].indexOf("文史类")>-1) {
	            					majorType="文史类";
	            				}
            				}
            				if(strArr.length>4) {
	            				if(strArr[4].indexOf("理工类")>-1) {
	            					majorType="理工类";
	            				}else if(strArr[4].indexOf("文史类")>-1) {
	            					majorType="文史类";
	            				}
            				}
            				
            				if("".equals(majorType)) {
            					System.out.println("-------strArr=--------"+strArr[1]+strArr[2]+"专业分类有误");
            					//return  "第"+(i+1)+"行数据"+strArr[1]+strArr[2]+"获取不到专业分类。";
            					
            					errorFlag=true;
    							errorSb.append("第"+(i+1)+"行数据"+strArr[1]+strArr[2]+"获取不到专业分类。"+"<br/>");
    							continue;
            				}else {
            					schoolPlan.setMajorType(majorType);
            				}
            				
            				
            				
            				SchoolPlan schoolPlanQuery=new SchoolPlan();
        			        schoolPlanQuery.setSchoolCode(schoolPlan.getSchoolCode());
        			        schoolPlanQuery.setYear(schoolPlan.getYear());            				
        			        schoolPlanQuery.setBatch(schoolPlan.getBatch());
        			        schoolPlanQuery.setMajorCode(schoolPlan.getMajorCode());
        			        schoolPlanQuery.setMajorType(schoolPlan.getMajorType());
            				
        			        List<SchoolPlan> list2=schoolPlanMapper.selectSchoolPlanList(schoolPlanQuery);
        			        if(list2!=null&&list2.size()>0) {
        			        	schoolPlanMapper.deleteSchoolPlanByScodeYearBatch(schoolPlanQuery);
        			        }

            				schoolPlanList.add(schoolPlan);
            				
            				
            			}
            		}else {
            			batch="高职高专普通批";
            			
            		}
            	}
            	
            	
            }
            
            if(errorFlag) {
            	return errorSb.toString();
            }
            
            if(schoolPlanList.size()>0) {
	            List<SchoolPlan> insertSchoolPlanList=new ArrayList();
	            int k=0;
	            for(int i=0;i<schoolPlanList.size();i++) {
	            	SchoolPlan plan=schoolPlanList.get(i);
	            	insertSchoolPlanList.add(plan);
	            	k++;
	            	if(k>500) {
	            		schoolPlanMapper.insertSchoolPlanList(insertSchoolPlanList);
	            		insertSchoolPlanList=new ArrayList();
	            		k=0;
	            	}
	            }
	            if(insertSchoolPlanList.size()>0) {
	            	schoolPlanMapper.insertSchoolPlanList(insertSchoolPlanList);
	            }
            }else {
            	return "没有导入任何数据，请核查导入文件";
            }
            
            
            SchoolPlan schoolPlanQuery=new SchoolPlan();
            schoolPlanQuery.setBatch(batch);
            schoolPlanQuery.setYear(new Integer(yearStr));
            schoolPlanQuery.setMajorType("理工类");
            List<SchoolPlan> lgList=schoolPlanMapper.selectSchoolPlanSumList(schoolPlanQuery);
            List<SchoolPlan> updateSchoolPlanList=new ArrayList();
            if(lgList!=null&&lgList.size()>0) {
            	int k=0;
            	for(int i=0;i<lgList.size();i++) {
            		SchoolPlan lg=lgList.get(i);
            		lg.setMajorLgPlan(lg.getMajorPlan());
            		updateSchoolPlanList.add(lg);
            		k++;
            		if(k>500) {
            			schoolPlanMapper.updateSchoolPlanLgList(updateSchoolPlanList);
            			updateSchoolPlanList=new ArrayList();
            			k=0;
            		}
            	}
            	if(updateSchoolPlanList.size()>0) {
            		schoolPlanMapper.updateSchoolPlanLgList(updateSchoolPlanList);
            	}
            }
            
            schoolPlanQuery=new SchoolPlan();
            schoolPlanQuery.setBatch(batch);
            schoolPlanQuery.setYear(new Integer(yearStr));
            schoolPlanQuery.setMajorType("文史类");
            List<SchoolPlan> wsList=schoolPlanMapper.selectSchoolPlanSumList(schoolPlanQuery);
            if(wsList!=null&&wsList.size()>0) {
            	updateSchoolPlanList=new ArrayList();
            	int k=0;
            	for(int i=0;i<wsList.size();i++) {
            		SchoolPlan ws=wsList.get(i);
            		ws.setMajorWsPlan(ws.getMajorPlan());
            		updateSchoolPlanList.add(ws);
            		k++;
            		if(k>500) {
            			schoolPlanMapper.updateSchoolPlanWsList(updateSchoolPlanList);
            			updateSchoolPlanList=new ArrayList();
            			k=0;
            		}
            	}
            	if(updateSchoolPlanList.size()>0) {
            		schoolPlanMapper.updateSchoolPlanWsList(updateSchoolPlanList);
            	}
            }
            
            
	    } catch (IOException e) {
	        e.printStackTrace();
	        throw new RuntimeException("导入失败");
	    } finally {
	        
	    }
	    return "成功";
    }
    
    
    public static String getNumberFromString(String str) {
        StringBuilder result = new StringBuilder();  // 存储提取出的数字
        boolean isNumberStart = false;  // 标记数字开始的位置
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (Character.isDigit(c)) {
                result.append(c);  // 将数字字符添加到结果中
                isNumberStart = true;  // 标记数字已经开始
            } else if (isNumberStart) {
                break;  // 如果数字已经开始，并且当前字符不是数字，则结束循环
            }
        }
        return result.toString();
    }
    
    public static int numericAt(String str){
		for (int i=0;i< str.length();i++){
			if (Character.isDigit(str.charAt(i))){
			return i;
			}
		}
		return -1;
	}
    
    @Override
    //@Transactional
	public String impPlan2024(String filePath,String dataType) {
		//String fileName= "D:\\666(8).xls";
		String fileName= filePath;
		File file = new File(fileName);
		
	    try {
	    	List<Object[]> list = new ArrayList<>();
	    	
	    	InputStream inputStream = new FileInputStream(fileName);
            Workbook workbook = WorkbookFactory.create(inputStream);
            Sheet sheet = workbook.getSheetAt(0);
            String sheetName=sheet.getSheetName();
            
            String yearStr="2024";
            //String gradeClass=sheetName.substring(5, 7);
            
            School school=new School();
            List<School> schoolList=schoolMapper.selectSchoolList(school);
            
          //取出数据库所有的专业
            List<SMajors> majorList=majorsMapper.selectSMajorsList(null);
            
            
            boolean errorFlag=false;
            StringBuffer errorSb=new StringBuffer();
            
            //获取sheet的行数
          //获取sheet的行数
            int rows = sheet.getLastRowNum();
            for (int i = 0; i <= rows; i++) {
            	//获取当前行的数据
                Row row = sheet.getRow(i);
                if(row!=null) {
	                Object[] objects = new Object[1];
	                int index = 0;
	                for (int j=0;j< 1;j++) {
	                	Cell cell=row.getCell(j);
	                	if(cell==null) {
	                		objects[index] = "";
	                	}else {
		                	if (cell.getCellType().equals(CellType.NUMERIC)) {
		                		int num=(int) cell.getNumericCellValue();
		                        objects[index] = new Integer(num).toString();
		                    }else {
		                    	objects[index] = cell.getStringCellValue();
		                    }
	                	}
	                	/*
	                	if (cell.getCellType().equals(CellType.STRING)) {
	                		objects[index] = cell.getStringCellValue();
	                	}
	                	*/
	                    
	                    index++;
	                }
	                list.add(objects);
                }
            }

            
            
            
            
            
            SchoolPlan schoolPlanYear=new SchoolPlan();	        
            schoolPlanYear.setYear(new Integer(yearStr));            				
	        List<SchoolPlan> list2=schoolPlanMapper.selectSchoolPlanList(schoolPlanYear);
            
            
            
            
            
            String lastSchoolCode="";
            String lastSchoolName="";
            Integer lastSchoolPlan=0;
            Integer lastMajorLgPlan=0;
            Integer lastMajorWsPlan=0;
            String batch="";
            
            String lastZyzCode="";
            String lastSxkm="";
            String lastZxkm="";
            String lastLineStr="";
            
            List<SchoolPlan> schoolPlanList=new ArrayList();
            
            for(int i=0;i<list.size();i++) {
            	Object[] objArr=list.get(i);
            	String str=(String)objArr[0];
            	
            	if(str!=null) {
            		System.out.println("-----str-------"+str);
            		
            		str=str.replaceAll("\\n", "");
            		str=str.replaceAll("1", "1");
            		str=str.replaceAll("I", "1");
            		str=str.replaceAll("l", "1");
            		str=str.replaceAll("o", "0");
            		str=str.replaceAll("O", "0");
            		str=str.trim();
            		
            		if(startsWithDigit(str)) {//这行内容以数字开头
            			
            			
            			boolean isSchool=false;
            			
            			
            			String startCode=getNumberFromString(str);
            			
            			startCode=startCode.trim();
            			
            			String[] strArr=new String[4];
            			
            			if (startCode.length() == 5) {//5位数字编码，可能是学校
    			        
	    			        
	            			for(int j=0;j<schoolList.size();j++) {
	            				School schoolObj=schoolList.get(j);
	            				
	            				try {
		            				if(startCode.equals(schoolObj.getScode())) {//如果数字=学校编号，这行是学校招生人数
		            					lastSchoolCode=startCode;
		            					
		            					lastSchoolName=schoolObj.getSname();
	
		            					String planRen=str.substring(5, str.length());
		            					StringBuilder number = new StringBuilder();
		            			        for (char c : planRen.toCharArray()) {
		            			            if (Character.isDigit(c)) {
		            			                number.append(c);
		            			            }
		            			        }
		            			        if (number.length() > 0) {
		            			        	lastSchoolPlan=new Integer(number.toString());
		            			        	
		            			        }
		            	
		            			        
		            			        
		            			        
		            					isSchool=true;
		            					break;
		            				}
	            				}catch(Exception e3) {
	            					System.out.println("第"+i+"行数据"+str+"错误。");
	            					errorFlag=true;
	    							errorSb.append("第"+i+"行数据"+str+"错误。<br/>");
	    							
	            					e3.printStackTrace();
	            					continue;
	            				}
	            				
	            			}
            			}
            			
            			if(isSchool) {//说明这行是学校信息
            				lastMajorLgPlan=0;
    			        	lastMajorWsPlan=0;

    			        	if(sheetName.indexOf("理工类")>0) {
    			        		lastMajorLgPlan=lastSchoolPlan;
    			        	}
    			        	if(sheetName.indexOf("文史类")>0) {
    			        		lastMajorWsPlan=lastSchoolPlan;
    			        	}

    			        	
            			}else {//这行不是学校信息，应该是专业信息了
            				
            				//判断数字是否3位数字
            				
        			        if (startCode.length() != 3) {//专业序号不是3位数字，跳过
        			        	continue;
        			        }
        			        try {
        			        	
        			        	
        			        	
	        			        String str2=str.replace(startCode, "");
	        			        
	        			        str2=str2.replaceAll(" ", "");
	        			        
	        			        String zymc="";
	        			        //是否有5+3
	        			        if(str2.indexOf("5+3")>-1) {
	        			        	zymc=str2.substring(0, str2.indexOf("5+3")+3);
	        			        	str2=str2.substring(str2.indexOf("5+3")+3, str2.length());
	        			        }
	        			        
	        			        if(str2.indexOf("5＋3")>-1) {
	        			        	zymc=str2.substring(0, str2.indexOf("5＋3")+3);
	        			        	str2=str2.substring(str2.indexOf("5＋3")+3, str2.length());
	        			        }
	        			        
	        			        if(str2.indexOf("5十3")>-1) {
	        			        	zymc=str2.substring(0, str2.indexOf("5十3")+3);
	        			        	str2=str2.substring(str2.indexOf("5十3")+3, str2.length());
	        			        }
	        			        
	        			        if(str2.indexOf("3加1")>-1) {
	        			        	zymc=str2.substring(0, str2.indexOf("3加1")+3);
	        			        	str2=str2.substring(str2.indexOf("3加1")+3, str2.length());
	        			        }
	        			        
	        			        if(str2.indexOf("3D")>-1) {
	        			        	zymc=str2.substring(0, str2.indexOf("3D")+2);
	        			        	str2=str2.substring(str2.indexOf("3D")+2, str2.length());
	        			        }
	        			        
	        			        if(str2.indexOf("3个专业")>-1) {
	        			        	zymc=str2.substring(0, str2.indexOf("3个专业")+4);
	        			        	str2=str2.substring(str2.indexOf("3个专业")+4, str2.length());
	        			        }
	        			        
	        			        if(str2.indexOf("创新实验班30人")>-1) {
	        			        	zymc=str2.substring(0, str2.indexOf("创新实验班30人")+8);
	        			        	str2=str2.substring(str2.indexOf("创新实验班30人")+8, str2.length());
	        			        }
	        			        
	        			        if(str2.indexOf("212商管理")>-1) {
	        			        	zymc=str2.substring(0, str2.indexOf("212商管理")+6);
	        			        	str2=str2.substring(str2.indexOf("212商管理")+6, str2.length());
	        			        }
	        			        
	        			        if(str2.indexOf("中美121")>-1) {
	        			        	zymc=str2.substring(0, str2.indexOf("中美121")+5);
	        			        	str2=str2.substring(str2.indexOf("中美121")+5, str2.length());
	        			        }
	        			        
	        			        if(str2.indexOf("2011计划")>-1) {
	        			        	zymc=str2.substring(0, str2.indexOf("2011计划")+6);
	        			        	str2=str2.substring(str2.indexOf("2011计划")+6, str2.length());
	        			        }
	        			        
	        			        if(str2.indexOf("瀚德2班")>-1) {
	        			        	zymc=str2.substring(0, str2.indexOf("瀚德2班")+4);
	        			        	str2=str2.substring(str2.indexOf("瀚德2班")+4, str2.length());
	        			        }
	        			        
	        			        if(str2.indexOf("5G")>-1) {
	        			        	zymc=str2.substring(0, str2.indexOf("5G")+2);
	        			        	str2=str2.substring(str2.indexOf("5G")+2, str2.length());
	        			        }
	        			        
	        			        if(str2.indexOf("5D")>-1) {
	        			        	zymc=str2.substring(0, str2.indexOf("5D")+2);
	        			        	str2=str2.substring(str2.indexOf("5D")+2, str2.length());
	        			        }
	        			        
	        			        if(str2.indexOf("8年制本博连读")>-1) {
	        			        	zymc=str2.substring(0, str2.indexOf("8年制本博连读")+7);
	        			        	str2=str2.substring(str2.indexOf("8年制本博连读")+7, str2.length());
	        			        }
	        			        
	        			        
	        			        
	        			        int b=numericAt(str2);
	        			        strArr[1]=str2.substring(0, b);
	        			        strArr[1]=strArr[1].trim();
	        			        zymc=zymc+strArr[1];
	        			        
	        			        str2=str2.substring(b, str2.length());
	        			        String startCode2=getNumberFromString(str2);
	        			        startCode2=startCode2.trim();
	        			        strArr[2]=startCode2;
	            				
	            				SchoolPlan schoolPlan=new SchoolPlan();
	            				schoolPlan.setSchoolCode(lastSchoolCode);
	            				schoolPlan.setSchoolName(lastSchoolName);
	            				schoolPlan.setSchoolPlan(lastSchoolPlan);
	            				schoolPlan.setYear(new Integer(yearStr));
	            				
	            				schoolPlan.setBatch(batch);
	            				
	            				schoolPlan.setMajorSeq(startCode);
	            				schoolPlan.setMajorLgPlan(lastMajorLgPlan);
	            				schoolPlan.setMajorWsPlan(lastMajorWsPlan);
	            				schoolPlan.setZyz(lastZyzCode);
	            				schoolPlan.setKm1(lastSxkm);
	            				schoolPlan.setKm2(lastZxkm);
	            				
	            				
	            				if(schoolPlan.getKm2()!=null&&!schoolPlan.getKm2().equals("")) {
	            		    		if(schoolPlan.getKm2().indexOf("＋")>0) {
	            		    			String[] km2Arr=schoolPlan.getKm2().split("＋");
	            		    			if(km2Arr[0].equals("思想政治")) {
	            		    				schoolPlan.setKm21("政治");
	            		    			}else {
	            		    				schoolPlan.setKm21(km2Arr[0]);
	            		    			}
	            		    			if(km2Arr.length>1) {
	            		    				if(km2Arr[1].equals("思想政治")) {
	            		    					schoolPlan.setKm22("政治");
	            			    			}else {
	            			    				schoolPlan.setKm22(km2Arr[1]);
	            			    			}
	            		    			}
	            		    			if(km2Arr.length>2) {
	            		    				if(km2Arr[2].equals("思想政治")) {
	            		    					schoolPlan.setKm23("政治");
	            			    			}else {
	            			    				schoolPlan.setKm23(km2Arr[2]);
	            			    			}
	            		    			}
	            		    		}else if(schoolPlan.getKm2().indexOf("+")>0) {
	            		    			String[] km2Arr=schoolPlan.getKm2().split("\\+");
	            		    			if(km2Arr[0].equals("思想政治")) {
	            		    				schoolPlan.setKm21("政治");
	            		    			}else {
	            		    				schoolPlan.setKm21(km2Arr[0]);
	            		    			}
	            		    			if(km2Arr.length>1) {
	            		    				if(km2Arr[1].equals("思想政治")) {
	            		    					schoolPlan.setKm22("政治");
	            			    			}else {
	            			    				schoolPlan.setKm22(km2Arr[1]);
	            			    			}
	            		    			}
	            		    			if(km2Arr.length>2) {
	            		    				if(km2Arr[2].equals("思想政治")) {
	            		    					schoolPlan.setKm23("政治");
	            			    			}else {
	            			    				schoolPlan.setKm23(km2Arr[2]);
	            			    			}
	            		    			}
	            		    		}else {
	            		    			if(schoolPlan.getKm2().equals("不限")) {
	            		    				
	            		    			}else {
	            			    			if(schoolPlan.getKm2().equals("思想政治")) {
	            			    				schoolPlan.setKm21("政治");
	            			    			}else {
	            			    				schoolPlan.setKm21(schoolPlan.getKm2());
	            			    			}
	            		    			}
	            		    		}
	            				}
	            				
	            				
	            				schoolPlan.setMajorPlan(new Integer(startCode2));
	            				
	            				schoolPlan.setCreateTime(new Date());
	            				
	            				String majorType="";
	            				if(lastSxkm.equals("物理")) {
	            					majorType="理工类";
	            				}
	            				if(lastSxkm.equals("历史")) {
	            					majorType="文史类";
	            				}
	            				
	            				schoolPlan.setMajorType(majorType);
	            				
	            				
	            				if(str.indexOf("国家专项计划")>-1) {
	            					schoolPlan.setRemark("国家专项计划");
	            				}
	            				if(str.indexOf("民族班")>-1) {
	            					schoolPlan.setRemark("民族班");
	            				}
	            				if(str.indexOf("中外合作办学")>-1) {
	            					schoolPlan.setRemark("中外合作办学");
	            				}
	            				
	            				if(str.indexOf("地方专项计划")>-1) {
	            					schoolPlan.setRemark("地方专项计划");
	            				}
	            				/*
	            				if(strArr.length<2) {
	            					errorFlag=true;
	    							errorSb.append("第"+(i)+"行数据："+str+"错误。<br/>");
	    							continue;
	            				}
	            				*/
	            				
	            				if(zymc.indexOf("，")>-1) {
	            					zymc=zymc.replaceAll("，", ",");
	        					}
	            				if(zymc.indexOf("（")>-1) {
	            					zymc=zymc.replaceAll("（", "(");
	        					}
	            				if(zymc.indexOf("）")>-1) {
	            					zymc=zymc.replaceAll("）", ")");
	        					}
        					
            				
            				
            					schoolPlan.setMajorName(zymc);
            					String mCode="";
            					boolean majorFlag=false;//专业名相同标志
		            			boolean majorKHFlag=false;//专业括号名相同标志
		            			int sameMajor=0;
		            			
            					for(int k=0;k<majorList.size();k++) {
            						SMajors sMajors=majorList.get(k);
            						if(sMajors.getMname().equals(zymc)) {
            							mCode=sMajors.getMcode();
            							schoolPlan.setMajorCode(mCode);
            							majorFlag=true;
            							break;
            						}
            					}
            					if(!majorFlag) {//如果专业不存在，需要插入专业表
            						if(zymc.indexOf("（")>-1) {//判断是否包含中文括号
			            				String major1=zymc.substring(0, zymc.indexOf("（"));//去掉括号后的专业名称
			            				String major2=zymc.substring( zymc.indexOf("（")+1,zymc.length());
			            				
			            				for(int m=0;m<majorList.size();m++) {
				            				SMajors majorObj2=majorList.get(m);
				            				String name2=majorObj2.getMname();
				            				if(name2.indexOf("(")>-1) {
				            					name2=name2.replaceAll("\\(", "（");
				            				}
				            				if(name2.indexOf(")")>-1) {
				            					name2=name2.replaceAll("\\)", "）");
				            				}
				            				if(name2.indexOf("，")>-1) {
				            					name2=name2.replaceAll("，", ",");
				            				}
				            				if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
				            					mCode=majorObj2.getMcode();
				            					//schoolPlan.setMajorCode(mCode);
				            					majorKHFlag=true;
				            					break;
				            				}
			            				}
			            				
			            				if(majorKHFlag) {//去掉括号后的专业名称存在，按序号增加
			            					
			            					for(int m=0;m<majorList.size();m++) {
					            				SMajors majorObj2=majorList.get(m);
					            				if(majorObj2.getMname().indexOf("（")>-1) {
					            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
						            				if(major3.equals(major1)) {
						            					sameMajor++;
						            				}
					            				}else if(majorObj2.getMname().indexOf("(")>-1) {
					            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
						            				if(major3.equals(major1)) {
						            					sameMajor++;
						            				}
					            				}else {
					            					if(majorObj2.getMname().equals(major1)) {
						            					sameMajor++;
						            				}
					            				}
					            				
			            					}
			            					String code="";
			            					sameMajor++;
			            					if(sameMajor>9) {
			            						code=new Integer(sameMajor).toString();
			            					}else {
			            						code="0"+sameMajor;
			            					}
			            					SMajors sMajors=new SMajors();
			            					sMajors.setMname(zymc);
			            					if(mCode!=null) {
			            						if(sMajors.getMname().indexOf("类")>-1) {
			            							sMajors.setMcode(mCode+"0"+code);
				            						schoolPlan.setMajorCode(mCode+"0"+code);
			            						}else {
			            							sMajors.setMcode(mCode+code);
				            						schoolPlan.setMajorCode(mCode+code);
			            						}
			            						
			            					}else {
			            						sMajors.setMcode(code);
			            						schoolPlan.setMajorCode(code);
			            					}
			            					sMajors.setCreateTime(new Date());
				            				majorsMapper.insertSMajors(sMajors);
				            				
				            				majorList.add(sMajors);
				            				
				            				
			            				}
            						}else if(zymc.indexOf("(")>-1) {//判断是否包含英文括号
			            				String major1=zymc.substring(0, zymc.indexOf("("));
			            				String major2=zymc.substring( zymc.indexOf("(")+1,zymc.length());
			            				
			            				for(int m=0;m<majorList.size();m++) {
				            				SMajors majorObj2=majorList.get(m);
				            				String name2=majorObj2.getMname();
				            				if(name2.indexOf("（")>-1) {
				            					name2=name2.replaceAll("（", "(");
				            				}
				            				if(name2.indexOf("）")>-1) {
				            					name2=name2.replaceAll("）", ")");
				            				}
				            				if(name2.indexOf("，")>-1) {
				            					name2=name2.replaceAll("，", ",");
				            				}
				            				if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
				            					mCode=majorObj2.getMcode();
				            					//schoolPlan.setMajorCode(mCode);
				            					majorKHFlag=true;
				            					break;
				            				}
			            				}
			            				
			            				if(majorKHFlag) {//去掉括号后的专业名称存在，按序号增加
			            					
			            					for(int m=0;m<majorList.size();m++) {
					            				SMajors majorObj2=majorList.get(m);
					            				if(majorObj2.getMname().indexOf("（")>-1) {
					            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
						            				if(major3.equals(major1)) {
						            					sameMajor++;
						            				}
					            				}else if(majorObj2.getMname().indexOf("(")>-1) {
					            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
						            				if(major3.equals(major1)) {
						            					sameMajor++;
						            				}
					            				}else {
					            					if(majorObj2.getMname().equals(major1)) {
						            					sameMajor++;
						            				}
					            				}
					            				
			            					}
			            					String code="";
			            					sameMajor++;
			            					if(sameMajor>9) {
			            						code=new Integer(sameMajor).toString();
			            					}else {
			            						code="0"+sameMajor;
			            					}
			            					SMajors sMajors=new SMajors();
			            					
			            					sMajors.setMname(zymc);
			            					if(mCode!=null) {
			            						if(sMajors.getMname().indexOf("类")>-1) {
			            							sMajors.setMcode(mCode+"0"+code);
				            						schoolPlan.setMajorCode(mCode+"0"+code);
			            						}else {
			            							sMajors.setMcode(mCode+code);
				            						schoolPlan.setMajorCode(mCode+code);
			            						}
			            					}else {
			            						sMajors.setMcode(code);
			            						schoolPlan.setMajorCode(code);
			            					}
			            					sMajors.setCreateTime(new Date());
				            				majorsMapper.insertSMajors(sMajors);
				            				
				            				majorList.add(sMajors);
				            				
				            				
			            				}
            						}else {//去掉括号后，专业名称也不存在，则需要增加这个新的专业
            							System.out.println("-------strArr=--------"+zymc);
                    					//return  "第"+(i+1)+"行数据"+zymc+"专业没有编码。";
            							errorFlag=true;
            							errorSb.append("第"+(i+1)+"行数据"+zymc+"专业没有编码。<br/>");
            							continue;
			            			}
            					}
            					
            					
            				
            				/*
            				try {
	            				String planRen=strArr[2];
	            				StringBuilder number = new StringBuilder();
	        			        for (char c : planRen.toCharArray()) {
	        			            if (Character.isDigit(c)) {
	        			                number.append(c);
	        			            }
	        			        }
	        			        if (number.length() >= 0) {
	        			        	schoolPlan.setMajorPlan(new Integer(number.toString()));
	        			        }else {
	        			        	System.out.println("-------strArr=--------"+zymc+strArr[2]);
	            					//return  "第"+(i+1)+"行数据"+zymc+strArr[2]+"招生人数有误。";
	            					errorFlag=true;
	    							errorSb.append("第"+(i+1)+"行数据"+zymc+strArr[2]+"招生人数有误。"+"<br/>");
	    							continue;
	        			        }
            				}catch(Exception ee) {
            					System.out.println("-------strArr=--------"+zymc);
            					//return  "第"+(i+1)+"行数据"+zymc+strArr[2]+"招生人数有误。错误信息："+ee.getMessage();
            					errorFlag=true;
    							errorSb.append("第"+(i+1)+"行数据"+zymc+"招生人数有误。错误信息："+ee.getMessage()+"<br/>");
    							continue;
            				}
            				*/
            				
            				
            				if(schoolPlan.getRemark()!=null) {
	            				if(schoolPlan.getRemark().indexOf("国家专项计划")>-1) {
	            					schoolPlan.setMajorCode(schoolPlan.getMajorCode()+"0");
	            				}
	            				if(schoolPlan.getRemark().indexOf("民族班")>-1) {
	            					schoolPlan.setMajorCode(schoolPlan.getMajorCode()+"00");
	            				}
	            				if(schoolPlan.getRemark().indexOf("地方专项计划")>-1) {
	            					schoolPlan.setMajorCode(schoolPlan.getMajorCode()+"000");
	            				}
            				}
            				/*
            				SchoolPlan schoolPlanQuery=new SchoolPlan();
        			        schoolPlanQuery.setSchoolCode(schoolPlan.getSchoolCode());
        			        schoolPlanQuery.setYear(schoolPlan.getYear());            				
        			        schoolPlanQuery.setBatch(schoolPlan.getBatch());
        			        schoolPlanQuery.setMajorCode(schoolPlan.getMajorCode());
        			        schoolPlanQuery.setMajorType(schoolPlan.getMajorType());
            				*/
        			        //List<SchoolPlan> list2=schoolPlanMapper.selectSchoolPlanList(schoolPlanQuery);
        			        /**
        			         * 验证数据库里是否有重复
        			         */
        			        if(list2!=null&&list2.size()>0) {
        			        	for(int j=0;j<list2.size();j++) {
        			        		SchoolPlan schoolPlanDb=list2.get(j);
        			        		if(schoolPlanDb!=null) {
	        			        		if(schoolPlan.getSchoolCode().equals(schoolPlanDb.getSchoolCode())
	        			        				&&schoolPlan.getBatch().equals(schoolPlanDb.getBatch())
	        			        				&&schoolPlan.getMajorCode().equals(schoolPlanDb.getMajorCode())
	        			        				&&schoolPlan.getMajorType().equals(schoolPlanDb.getMajorType())) {
	        			        			schoolPlanMapper.deleteSchoolPlanByScodeYearBatch(schoolPlanDb);
	        			        		}
        			        		}
        			        	}
        			        	
        			        }
            				

            				schoolPlanList.add(schoolPlan);
            				
        			        }catch(Exception ee) {
            					System.out.println("-------strArr=--------"+strArr[1]);
            					//return  "第"+(i+1)+"行数据"+strArr[1]+"专业有误。错误信息："+ee.getMessage();
            					errorFlag=true;
    							errorSb.append("第"+(i+1)+"行数据"+strArr[1]+"专业有误。错误信息："+ee.getMessage()+"<br/>");
    							continue;
            				}
            			}
            		}else if(str.indexOf("批")>-1) {
            				batch=str;           			
            		}else if(str.indexOf("专业组")>-1) {
            			try {
	            			str=str.trim();
	            			if(str.indexOf("(")>-1) {
	            				lastZyzCode=str.substring(4, str.indexOf("("));
	            			}else if(str.indexOf("（")>-1) {
	            				lastZyzCode=str.substring(4, str.indexOf("（"));
	            			}
	            			if(str.indexOf(",")>-1) {
	            				lastSxkm=str.substring(str.indexOf("首选科目")+5, str.indexOf(","));
	            			}else if(str.indexOf("，")>-1) {
	            				lastSxkm=str.substring(str.indexOf("首选科目")+5, str.indexOf("，"));
	            			}else if(str.indexOf("。")>-1) {
	            				lastSxkm=str.substring(str.indexOf("首选科目")+5, str.indexOf("。"));
	            			}
	            			
	            			if(str.indexOf("再选科目")>-1) {//有再选科目再选科目
	            				str=str.trim();
	            				if(str.indexOf(")")>-1) {
	            					lastZxkm=str.substring(str.indexOf("再选科目")+5, str.indexOf(")"));
	            				}else if(str.indexOf("）")>-1) {
	            					lastZxkm=str.substring(str.indexOf("再选科目")+5, str.indexOf("）"));
	            				}
	            				
	            			}
            			}catch(Exception ee) {
        					System.out.println("-------strArr=--------"+str);
        					//return  "第"+(i+1)+"行数据"+strArr[1]+"专业有误。错误信息："+ee.getMessage();
        					errorFlag=true;
							errorSb.append("第"+(i+1)+"行数据"+str+"专业有误。错误信息："+ee.getMessage()+"<br/>");
							continue;
        				}
            		}else {//再选科目
            			if(lastLineStr.indexOf("专业组")>-1) {//上一行是专业组，所以这一行是再选科目
            				
            				if(str.indexOf("再选科目")>-1) {//有再选科目再选科目
                				str=str.trim();
                				if(str.indexOf(")")>-1) {
                					lastZxkm=str.substring(str.indexOf("再选科目")+5, str.indexOf(")"));
                				}else if(str.indexOf("）")>-1) {
                					lastZxkm=str.substring(str.indexOf("再选科目")+5, str.indexOf("）"));
                				}
                				
                			}else {
                				if(!startsWithDigit(str)) {//这行内容以数字开头
	                				str=str.trim();
	                				if(str.indexOf(")")>-1) {
	                					lastZxkm=str.substring(0, str.indexOf(")"));
	                				}else if(str.indexOf("）")>-1) {
	                					lastZxkm=str.substring(0, str.indexOf("）"));
	                				}
                				}
                				
                			}

            			}
            		}
            		
            		
            		lastLineStr=str;
            	}
            	
            	
            }
            
            if(errorFlag) {
            	return errorSb.toString();
            }
            
            if(schoolPlanList.size()>0) {
	            List<SchoolPlan> insertSchoolPlanList=new ArrayList();
	            int k=0;
	            for(int i=0;i<schoolPlanList.size();i++) {
	            	SchoolPlan plan=schoolPlanList.get(i);
	            	insertSchoolPlanList.add(plan);
	            	k++;
	            	if(k>500) {
	            		schoolPlanMapper.insertSchoolPlanList2024(insertSchoolPlanList);
	            		insertSchoolPlanList=new ArrayList();
	            		k=0;
	            	}
	            }
	            if(insertSchoolPlanList.size()>0) {
	            	schoolPlanMapper.insertSchoolPlanList2024(insertSchoolPlanList);
	            }
            }else {
            	return "没有导入数据";
            }
            
            
            SchoolPlan schoolPlanQuery=new SchoolPlan();
            schoolPlanQuery.setBatch(batch);
            schoolPlanQuery.setYear(new Integer(yearStr));
            schoolPlanQuery.setMajorType("理工类");
            List<SchoolPlan> lgList=schoolPlanMapper.selectSchoolPlanSumList(schoolPlanQuery);
            List<SchoolPlan> updateSchoolPlanList=new ArrayList();
            if(lgList!=null&&lgList.size()>0) {
            	int k=0;
            	for(int i=0;i<lgList.size();i++) {
            		SchoolPlan lg=lgList.get(i);
            		lg.setMajorLgPlan(lg.getMajorPlan());
            		updateSchoolPlanList.add(lg);
            		k++;
            		if(k>500) {
            			schoolPlanMapper.updateSchoolPlanLgList(updateSchoolPlanList);
            			updateSchoolPlanList=new ArrayList();
            			k=0;
            		}
            	}
            	if(updateSchoolPlanList.size()>0) {
            		schoolPlanMapper.updateSchoolPlanLgList(updateSchoolPlanList);
            	}
            }
            
            schoolPlanQuery=new SchoolPlan();
            schoolPlanQuery.setBatch(batch);
            schoolPlanQuery.setYear(new Integer(yearStr));
            schoolPlanQuery.setMajorType("文史类");
            List<SchoolPlan> wsList=schoolPlanMapper.selectSchoolPlanSumList(schoolPlanQuery);
            if(wsList!=null&&wsList.size()>0) {
            	updateSchoolPlanList=new ArrayList();
            	int k=0;
            	for(int i=0;i<wsList.size();i++) {
            		SchoolPlan ws=wsList.get(i);
            		ws.setMajorWsPlan(ws.getMajorPlan());
            		updateSchoolPlanList.add(ws);
            		k++;
            		if(k>500) {
            			schoolPlanMapper.updateSchoolPlanWsList(updateSchoolPlanList);
            			updateSchoolPlanList=new ArrayList();
            			k=0;
            		}
            	}
            	if(updateSchoolPlanList.size()>0) {
            		schoolPlanMapper.updateSchoolPlanWsList(updateSchoolPlanList);
            	}
            }
            
            
	    } catch (IOException e) {
	        e.printStackTrace();
	        throw new RuntimeException("导入失败");
	    } finally {
	        
	    }
	    return "成功";
    }
    
    public String fixData() {
    	List<SchoolMajorYearAdmission> list=schoolMajorYearAdmissionMapper.selectEmptyMajorCodeList(null);
    	schoolMajorYearAdmissionMapper.fixSchoolMajorCodeEmptyList(list);
    	/*
    	for(int i=0;i<list.size();i++) {
    		SchoolMajorYearAdmission admin=list.get(i);
    		
    	}
    	*/
    	return "成功";
    }

	@Override
	//@Transactional
	public String imp(String filePath,String dataType) {
		//String fileName= "D:\\020(4).xls"; 
		String fileName= filePath; 
		File file = new File(fileName);
		
		boolean errorFlag=false;
        StringBuffer errorSb=new StringBuffer();
		
	    try {
	    	List<Object[]> list = new ArrayList<>();
	    	
	    	InputStream inputStream = new FileInputStream(fileName);
            Workbook workbook = WorkbookFactory.create(inputStream);
            Sheet sheet = workbook.getSheetAt(0);
            //获取sheet的行数
            int rows = sheet.getLastRowNum();
            for (int i = 0; i <= rows; i++) {
            	//获取当前行的数据
                Row row = sheet.getRow(i);
                if(row!=null) {
	                Object[] objects = new Object[row.getLastCellNum()];
	                int index = 0;
	                for (int j=0;j< row.getLastCellNum();j++) {
	                	Cell cell=row.getCell(j);
	                	if(cell==null) {
	                		objects[index] = "";
	                	}else {
		                	if (cell.getCellType().equals(CellType.NUMERIC)) {
		                		int num=(int) cell.getNumericCellValue();
		                        objects[index] = new Integer(num).toString();
		                    }else {
		                    	objects[index] = cell.getStringCellValue();
		                    }
	                	}
	                	/*
	                	if (cell.getCellType().equals(CellType.STRING)) {
	                		objects[index] = cell.getStringCellValue();
	                	}
	                	*/
	                    
	                    index++;
	                }
	                list.add(objects);
                }
            }
            
            
            //取出数据库所有的专业
            List<SMajors> majorList=majorsMapper.selectSMajorsList(null);
            
            List<SchoolYearAdmission> schoolYearAdmissionList=new ArrayList();
            List<SchoolMajorYearAdmission> schoolMajorYearAdmissionList=new ArrayList();
            List<SchoolMajorYearAdmissionDetail> schoolMajorYearAdmissionDetailList=new ArrayList();
            
            List<SchoolYearAdmission> updateSchoolYearAdmissionLgPlanList=new ArrayList();
            List<SchoolYearAdmission> updateSchoolYearAdmissionWsPlanList=new ArrayList();
            
            int lastYear=0;
        	String lastSchoolCode="";
        	String lastSchoolName="";
        	String lastBatch="";
        	Long schoolYearAdmissionId=null;
        	
        	int lastPlan=-1;
        	int lastSubmit=-1;
        	int lastAdmisson=-1;
        	
        	
        	int lastPlanLg=-1;
        	int lastSubmitLg=-1;
        	int lastAdmissonLg=-1;
        	
        	int lastPlanWs=-1;
        	int lastSubmitWs=-1;
        	int lastAdmissonWs=-1;
        	
        	String lastMajor="";
        	String lastMajorType="";
            for(int i=0;i<list.size();i++) {
            	Object[] objArr=list.get(i);
            	if(objArr!=null&&objArr.length>0&&objArr[0]!=null) {
            	String obj1=objArr[0].toString();
            	obj1=obj1.trim();
            	int year=0;
            	String schoolCode="";
            	String schoolName="";
            	String batch="";
            	
            	String major="";
            	int plan=-1;
            	int submit=-1;
            	int admisson=-1;
            	String gradeStr="";
            	if(obj1!=null) {
	            	if(obj1.startsWith("年份")) {
	            		//一个新的学校
	            		String yearStr=obj1.substring(obj1.indexOf("年份")+3, obj1.indexOf("院校代码"));
	            		yearStr=yearStr.trim();
	            		try {
	            			year=new Integer(yearStr);
	            		}catch(Exception e3) {
	            			errorFlag=true;
							errorSb.append("第"+i+"行数据："+obj1+"的年份错误");
	            		}
	            		schoolCode=obj1.substring(obj1.indexOf("院校代码")+5, obj1.indexOf("院校名称"));
	            		schoolCode=schoolCode.trim();
	            		schoolName=obj1.substring(obj1.indexOf("院校名称")+5, obj1.indexOf("录取批次"));
	            		schoolName=schoolName.trim();
	            		batch=obj1.substring(obj1.indexOf("录取批次")+5, obj1.length());
	            		batch=batch.trim();
	            		
	            		lastMajorType="";
	            		
	            		SchoolYearAdmission schoolYearAdmissionQuery=new SchoolYearAdmission();
	            		schoolYearAdmissionQuery.setsCode(schoolCode);
	            		schoolYearAdmissionQuery.setYear(year);
	            		schoolYearAdmissionQuery.setBatch(batch);
	            		List<SchoolYearAdmission> existList= schoolYearAdmissionMapper.selectSchoolYearAdmissionList(schoolYearAdmissionQuery);
	            		if(existList!=null&&existList.size()>0) {
	            			/**
	            			 * 删除相关数据，重新插入
	            			 */
	            			
	            			schoolYearAdmissionMapper.deleteSchoolYearAdmissionByScodeYearBatch(schoolYearAdmissionQuery);
	            			
	            			SchoolMajorYearAdmission schoolMajorYearAdmission=new SchoolMajorYearAdmission();
		            		schoolMajorYearAdmission.setsCode(schoolCode);
		            		schoolMajorYearAdmission.setYear(year);
		            		schoolMajorYearAdmission.setBatch(batch);
		            		schoolMajorYearAdmissionMapper.deleteSchoolMajorYearAdmissionByScodeYearBatch(schoolMajorYearAdmission);
		            		
		            		SchoolMajorYearAdmissionDetail schoolMajorYearAdmissionDetail=new SchoolMajorYearAdmissionDetail();
                			schoolMajorYearAdmissionDetail.setsCode(schoolCode);
                			schoolMajorYearAdmissionDetail.setYear(year);
                			schoolMajorYearAdmissionDetail.setBatch(batch);
                			schoolMajorYearAdmissionDetailMapper.deleteSchoolMajorYearAdmissionDetailByByScodeYearBatch(schoolMajorYearAdmissionDetail);

	            			
	            			
	            			SchoolYearAdmission schoolYearAdmission=new SchoolYearAdmission();
	            			schoolYearAdmission.setsCode(schoolCode);
		            		schoolYearAdmission.setYear(year);
		            		schoolYearAdmission.setBatch(batch);
		            		schoolYearAdmissionList.add(schoolYearAdmission);
		            		
		            		lastSchoolCode=schoolCode;
		            		lastSchoolName=schoolName;
		            		lastBatch=batch;
		            		lastYear=year;
	            		}else {
		            		SchoolYearAdmission schoolYearAdmission=new SchoolYearAdmission();
		            		schoolYearAdmission.setsCode(schoolCode);
		            		schoolYearAdmission.setYear(year);
		            		schoolYearAdmission.setBatch(batch);
		            		schoolYearAdmissionList.add(schoolYearAdmission);
		            		
		            		lastSchoolCode=schoolCode;
		            		lastSchoolName=schoolName;
		            		lastBatch=batch;
		            		lastYear=year;
	            		}
	            		
	            	}else if(obj1.startsWith("科目组及专业名称")) {
	            		//本行是标题，跳过
	            	}else {//统计专业
	            		if(!obj1.equals("")) {
	            			major=obj1.replaceAll("\\n", "");	  
	            			major=major.trim();
	            			if(major.indexOf("，")>-1) {
	            				major=major.replaceAll("，", ",");
        					}
	            			
	            			if(major.indexOf("（")>-1) {
	            				major=major.replaceAll("（", "(");
            				}
            				if(major.indexOf("）")>-1) {
            					major=major.replaceAll("）", ")");
            				}
	            			
	            			try {
		            			if(objArr[1]!=null) {
			            			String planStr=(String)objArr[1];
			            			planStr=planStr.replaceAll("\\n", "");	  
			            			planStr=planStr.trim();
			            			if(!planStr.equals("")) {
			            				plan=new Integer(planStr);
			            			}
			            		}
			            		if(objArr[2]!=null) {
			            			String submitStr=(String)objArr[2];
			            			submitStr=submitStr.replaceAll("\\n", "");	
			            			submitStr=submitStr.trim();
			            			if(!submitStr.equals("")) {
			            				submit=new Integer(submitStr);
			            			}
			            		}
			            		if(objArr[3]!=null) {
			            			String admissonStr=(String)objArr[3];
			            			admissonStr=admissonStr.replaceAll("\\n", "");	 
			            			admissonStr=admissonStr.trim();
			            			if(!admissonStr.equals("")) {
			            				admisson=new Integer(admissonStr);
			            			}
			            		}
			            		if(objArr.length>4) {
				            		if(objArr[4]!=null) {
				            			gradeStr=(String)objArr[4];
				            			gradeStr=gradeStr.replaceAll("\\n", "");	 
				            			gradeStr=gradeStr.trim();
				            		}
			            		}
	            			}catch(Exception e3) {
	            				errorFlag=true;
    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据");
    							if(objArr.length>1) {
    								errorSb.append(objArr[1]);
    							}
    							if(objArr.length>2) {
    								errorSb.append(objArr[2]);
    							}
    							if(objArr.length>3) {
    								errorSb.append(objArr[3]);
    							}
    							if(objArr.length>4) {
    								errorSb.append(objArr[4]);
    							}
    							errorSb.append("错误。<br/>");
    							continue;
	            			}
		            		
		            		if(!major.equals("")) {
		            			
		            			boolean majorFlag=false;//专业名相同标志
		            			boolean majorKHFlag=false;//专业括号名相同标志
		            			int sameMajor=0;
		            			String majorCode="";
		            			
		            			if("理工类".equals(major)) {
		            				lastMajorType="理工类";
		            				
		            				SchoolYearAdmission schoolYearAdmission=new SchoolYearAdmission();
				            		schoolYearAdmission.setsCode(lastSchoolCode);
				            		schoolYearAdmission.setYear(lastYear);
				            		schoolYearAdmission.setBatch(lastBatch);
				            		if(admisson==-1) {
				            			schoolYearAdmission.setAdmissionLg(0);
				            		}else {
				            			schoolYearAdmission.setAdmissionLg(admisson);
				            		}
				            		
				            		if(plan==-1) {
				            			schoolYearAdmission.setPlanLg(0);
				            		}else {
				            			schoolYearAdmission.setPlanLg(plan);
				            		}
				            		if(submit==-1) {
				            			schoolYearAdmission.setSubmitLg(0);
				            		}else {
				            			schoolYearAdmission.setSubmitLg(submit);
				            		}
				            		
				            		updateSchoolYearAdmissionLgPlanList.add(schoolYearAdmission);

		            			}else if("文史类".equals(major)) {
		            				lastMajorType="文史类";
		            				
		            				SchoolYearAdmission schoolYearAdmission=new SchoolYearAdmission();
				            		schoolYearAdmission.setsCode(lastSchoolCode);
				            		schoolYearAdmission.setYear(lastYear);
				            		schoolYearAdmission.setBatch(lastBatch);
				            		if(admisson==-1) {
				            			schoolYearAdmission.setAdmissionWs(0);
				            		}else {
				            			schoolYearAdmission.setAdmissionWs(admisson);
				            		}
				            		if(plan==-1) {
				            			
				            		}else {
				            			schoolYearAdmission.setPlanWs(plan);
				            		}
				            		if(submit==-1) {
				            			schoolYearAdmission.setSubmitWs(0);
				            		}else {
				            			schoolYearAdmission.setSubmitWs(submit);
				            		}
				            		
				            		updateSchoolYearAdmissionWsPlanList.add(schoolYearAdmission);
		            			}else {
		            			
			            			for(int k=0;k<majorList.size();k++) {
			            				SMajors majorObj=majorList.get(k);
			            				if(majorObj.getMname().equals(major)) {//如果专业存在，不做处理
			            					majorCode=majorObj.getMcode();
			            					majorFlag=true;
			            					break;
			            				}
			            			}
			            			if(!majorFlag) {//如果专业不存在，需要插入专业表
			            				if(major.indexOf("（")>-1&&major.indexOf("）")>-1) {//判断是否包含中文括号
				            				String major1=major.substring(0, major.indexOf("（"));
				            				String major2=major.substring( major.indexOf("（")+1,major.length());
				            				
				            				for(int m=0;m<majorList.size();m++) {
					            				SMajors majorObj2=majorList.get(m);
					            				String name2=majorObj2.getMname();
					            				if(name2.indexOf("(")>-1) {
					            					name2=name2.replaceAll("\\(", "（");
					            				}
					            				if(name2.indexOf(")")>-1) {
					            					name2=name2.replaceAll("\\)", "）");
					            				}
					            				if(name2.indexOf("，")>-1) {
					            					name2=name2.replaceAll("，", ",");
					            				}
					            				if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
					            					majorCode=majorObj2.getMcode();
					            					majorKHFlag=true;
					            					break;
					            				}
				            				}
				            				
				            				if(majorKHFlag) {
				            					
				            					for(int m=0;m<majorList.size();m++) {
						            				SMajors majorObj2=majorList.get(m);
						            				if(majorObj2.getMname().indexOf("（")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else if(majorObj2.getMname().indexOf("(")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else {
						            					if(majorObj2.getMname().equals(major1)) {
							            					sameMajor++;
							            				}
						            				}
						            				
				            					}
				            					String code="";
				            					sameMajor++;
				            					if(sameMajor>9) {
				            						code=new Integer(sameMajor).toString();
				            					}else {
				            						code="0"+sameMajor;
				            					}
				            					SMajors sMajors=new SMajors();
				            					sMajors.setMname(major);
				            					if(majorCode!=null) {
				            						if(sMajors.getMname().indexOf("类")>-1) {
				            							sMajors.setMcode(majorCode+"0"+code);
				            							majorCode=majorCode+"0"+code;
				            						}else {
				            							sMajors.setMcode(majorCode+code);
				            							majorCode=majorCode+code;
				            						}
				            					}else {
				            						sMajors.setMcode(code);
				            						majorCode=code;
				            					}
				            					sMajors.setCreateTime(new Date());
					            				majorsMapper.insertSMajors(sMajors);
					            				
					            				majorList.add(sMajors);
				            				}
				            				
				            			}else if(major.indexOf("(")>-1&&major.indexOf(")")>-1) {//判断是否包含中文括号
				            				String major1=major.substring(0, major.indexOf("("));
				            				String major2=major.substring( major.indexOf("(")+1,major.length());
				            				
				            				for(int m=0;m<majorList.size();m++) {
					            				SMajors majorObj2=majorList.get(m);
					            				String name2=majorObj2.getMname();
					            				if(name2.indexOf("（")>-1) {
					            					name2=name2.replaceAll("（", "(");
					            				}
					            				if(name2.indexOf("）")>-1) {
					            					name2=name2.replaceAll("）", ")");
					            				}
					            				if(name2.indexOf("，")>-1) {
					            					name2=name2.replaceAll("，", ",");
					            				}
					            				if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
					            					majorCode=majorObj2.getMcode();
					            					majorKHFlag=true;
					            					break;
					            				}
				            				}
				            				
				            				if(majorKHFlag) {
				            					
				            					for(int m=0;m<majorList.size();m++) {
						            				SMajors majorObj2=majorList.get(m);
						            				if(majorObj2.getMname().indexOf("（")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else if(majorObj2.getMname().indexOf("(")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else {
						            					if(majorObj2.getMname().equals(major1)) {
							            					sameMajor++;
							            				}
						            				}
						            				
				            					}
				            					String code="";
				            					sameMajor++;
				            					if(sameMajor>9) {
				            						code=new Integer(sameMajor).toString();
				            					}else {
				            						code="0"+sameMajor;
				            					}
				            					SMajors sMajors=new SMajors();
				            					sMajors.setMname(major);
				            					if(majorCode!=null) {
				            						if(sMajors.getMname().indexOf("类")>-1) {
				            							sMajors.setMcode(majorCode+"0"+code);
				            							majorCode=majorCode+"0"+code;
				            						}else {
				            							sMajors.setMcode(majorCode+code);
				            							majorCode=majorCode+code;
				            						}
				            					}else {
				            						sMajors.setMcode(code);
				            						majorCode=code;
				            					}
				            					sMajors.setCreateTime(new Date());
					            				majorsMapper.insertSMajors(sMajors);
					            				
					            				majorList.add(sMajors);
				            				}
				            				
				            			} else {
				            				//后面要改
				            				errorFlag=true;
			    							errorSb.append("第"+i+"行数据"+major+"专业编码不存在。<br/>");
				            				continue;
			    							/*
				            				SMajors sMajors=new SMajors();
				            				sMajors.setMname(major);
				            				sMajors.setMcode("000000");
				            				majorsMapper.insertSMajors(sMajors);
				            				
				            				majorList.add(sMajors);
				            				*/
				            				
				            			}
			            			}
		            			}
		            			
		            			
		            		
			            		SchoolMajorYearAdmission schoolMajorYearAdmission=new SchoolMajorYearAdmission();
			            		schoolMajorYearAdmission.setsCode(lastSchoolCode);
			            		schoolMajorYearAdmission.setMajor(major);
			            		schoolMajorYearAdmission.setMajorCode(majorCode);
			            		schoolMajorYearAdmission.setYear(lastYear);
			            		schoolMajorYearAdmission.setMajorType(lastMajorType);
			            		schoolMajorYearAdmission.setBatch(lastBatch);
			            		if(plan!=-1) {
			            			schoolMajorYearAdmission.setPlan(plan);
			            		}
			            		if(submit!=-1) {
			            			schoolMajorYearAdmission.setSubmit(submit);
			            		}
			            		if(admisson!=-1) {
			            			schoolMajorYearAdmission.setAdmission(admisson);
			            		}
			            		
			            		if(admisson!=-1&&plan==-1) {
			            			errorFlag=true;
	    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的计划数为空");
	    							continue;
			            		}
			            		/*
			            		if(admisson>plan) {
			            			errorFlag=true;
	    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的投档数和计划数不对");
	    							continue;
			            		}
			            		*/
			            		schoolMajorYearAdmissionList.add(schoolMajorYearAdmission);
			            		
			            		lastMajor=major;
		            		}//专业不为空时判断结束
		            		
		            		//下面开始统计成绩
		            		if(major.equals("")) major=lastMajor;
		            		
		            		lastPlan=plan;
		                	lastSubmit=submit;
		                	lastAdmisson=admisson;
		                	
		                	
		                	if(gradeStr!=null&&gradeStr.length()>0) {
		                		gradeStr=gradeStr.replaceAll("\\n", "");
		                		if(gradeStr.indexOf(".")>-1) gradeStr=gradeStr.substring(0, gradeStr.indexOf("."));
		                		if(gradeStr.indexOf("．")>-1) gradeStr=gradeStr.substring(0, gradeStr.indexOf("．"));
			                	if(gradeStr.indexOf(";")>-1) {
			                		String[]  gradeStrArr=gradeStr.split(";");
			                		for(int j=0;j<gradeStrArr.length;j++) {
			                			String gradeStrj=gradeStrArr[j];
			                			gradeStrj=gradeStrj.trim();
			                			String[] gradeArr=gradeStrj.split(":");
			                			if(gradeArr.length==2) {
			                				if(!gradeArr[0].trim().equals("")&&!gradeArr[1].trim().equals("")) {
			                					try {
						                			SchoolMajorYearAdmissionDetail schoolMajorYearAdmissionDetail=new SchoolMajorYearAdmissionDetail();
						                			schoolMajorYearAdmissionDetail.setAdmission(new Integer(gradeArr[1].trim()));
						                			schoolMajorYearAdmissionDetail.setGrade(new Integer(gradeArr[0].trim()));
						                			
						                			if(schoolMajorYearAdmissionDetail.getGrade()>740||schoolMajorYearAdmissionDetail.getGrade()<300) {
						                				errorFlag=true;
				                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的成绩"+gradeArr[0].trim()+"错误。<br/>");
				                						continue;
						                			}
						                			
						                			schoolMajorYearAdmissionDetail.setMajor(major);
						                			schoolMajorYearAdmissionDetail.setsCode(lastSchoolCode);
						                			schoolMajorYearAdmissionDetail.setYear(lastYear);
						                			schoolMajorYearAdmissionDetail.setBatch(lastBatch);
						                			schoolMajorYearAdmissionDetail.setMajorType(lastMajorType);
						                			
						                			schoolMajorYearAdmissionDetailList.add(schoolMajorYearAdmissionDetail);
			                					}catch(Exception e2) {
			                						System.out.println("-------------------ee:"+gradeStrj+",lastMajor:"+major+",lastSchoolCode:"+lastSchoolCode);
			                						errorFlag=true;
			                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeArr[0].trim()+";"+gradeArr[1].trim()+"错误。<br/>");
			                					}
			                				}
			                			}else {
			                				System.out.println("-------------------ee:"+gradeStrj);
			                				errorFlag=true;
			    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeStrj+"错误。<br/>");
			                			}
			                		}
			                	}else {
			                		String[] gradeArr=gradeStr.split(":");			
			                		try {
				                		if(gradeArr.length==2) {
				                			if(!gradeArr[0].trim().equals("")&&!gradeArr[1].trim().equals("")) {
					                			SchoolMajorYearAdmissionDetail schoolMajorYearAdmissionDetail=new SchoolMajorYearAdmissionDetail();
					                			schoolMajorYearAdmissionDetail.setAdmission(new Integer(gradeArr[1].trim()));
					                			schoolMajorYearAdmissionDetail.setGrade(new Integer(gradeArr[0].trim()));
					                			
					                			if(schoolMajorYearAdmissionDetail.getGrade()>720||schoolMajorYearAdmissionDetail.getGrade()<300) {
					                				errorFlag=true;
			                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的成绩"+gradeArr[0].trim()+"错误。<br/>");
			                						continue;
					                			}
					                			
					                			schoolMajorYearAdmissionDetail.setMajor(major);
					                			schoolMajorYearAdmissionDetail.setsCode(lastSchoolCode);
					                			schoolMajorYearAdmissionDetail.setYear(lastYear);
					                			schoolMajorYearAdmissionDetail.setBatch(lastBatch);
					                			schoolMajorYearAdmissionDetail.setMajorType(lastMajorType);
					                			
					                			schoolMajorYearAdmissionDetailList.add(schoolMajorYearAdmissionDetail);
				                			}
				                		}else {
	                						errorFlag=true;
	                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeStr+"错误。<br/>");
			                			}
			                		}catch(Exception e1) {
		                				errorFlag=true;
		    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeArr[0].trim()+";"+gradeArr[1].trim()+"错误。<br/>");
			                		}
			                	}
		                	}
		            		
	            		}else {//这一行对象是空的
	            			
	            			if(major.equals("")) major=lastMajor;
	            			
	            			if(objArr.length>4) {
		            			if(objArr[4]!=null) {
			            			gradeStr=(String)objArr[4];
			            			gradeStr=gradeStr.replaceAll("\\n", "");	 
			            			gradeStr=gradeStr.trim();
			            		}
	            			}
	            			
	            			if(gradeStr!=null&&gradeStr.length()>0) {
	            				gradeStr=gradeStr.replaceAll("\\n", "");
	            				gradeStr=gradeStr.trim();
		                		if(gradeStr.indexOf(".")>-1) gradeStr=gradeStr.substring(0, gradeStr.indexOf("."));
		                		if(gradeStr.indexOf("．")>-1) gradeStr=gradeStr.substring(0, gradeStr.indexOf("．"));
			                	if(gradeStr.indexOf(";")>-1) {
			                		String[]  gradeStrArr=gradeStr.split(";");
			                		
			                		for(int j=0;j<gradeStrArr.length;j++) {
			                			String gradeStrj=gradeStrArr[j];
			                			gradeStrj=gradeStrj.trim();
			                			String[] gradeArr=gradeStrj.split(":");
			                			if(gradeArr.length==2) {
			                				try {
				                				if(!gradeArr[0].trim().equals("")&&!gradeArr[1].trim().equals("")) {
						                			SchoolMajorYearAdmissionDetail schoolMajorYearAdmissionDetail=new SchoolMajorYearAdmissionDetail();
						                			schoolMajorYearAdmissionDetail.setAdmission(new Integer(gradeArr[1].trim()));
						                			schoolMajorYearAdmissionDetail.setGrade(new Integer(gradeArr[0].trim()));
						                			schoolMajorYearAdmissionDetail.setMajor(major);
						                			schoolMajorYearAdmissionDetail.setsCode(lastSchoolCode);
						                			schoolMajorYearAdmissionDetail.setYear(lastYear);
						                			schoolMajorYearAdmissionDetail.setBatch(lastBatch);
						                			schoolMajorYearAdmissionDetail.setMajorType(lastMajorType);
						                			
						                			if(schoolMajorYearAdmissionDetail.getGrade()>720||schoolMajorYearAdmissionDetail.getGrade()<300) {
						                				errorFlag=true;
				                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的成绩"+gradeArr[0].trim()+"错误。<br/>");
				                						continue;
						                			}
						                			
						                			schoolMajorYearAdmissionDetailList.add(schoolMajorYearAdmissionDetail);
				                				}
			                				}catch(Exception e2) {
		                						System.out.println("-------------------ee:"+gradeStrj+",lastMajor:"+major+",lastSchoolCode:"+lastSchoolCode);
		                						errorFlag=true;
		                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeArr[0].trim()+";"+gradeArr[1].trim()+"错误。<br/>");
		                					}
			                			}else {
			                				System.out.println("-------------------ee:"+gradeStrj+",lastMajor:"+major+",lastSchoolCode:"+lastSchoolCode);
			                				errorFlag=true;
	                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeStr+"错误。<br/>");
			                			}
			                		}
			                	}else {
			                		String[] gradeArr=gradeStr.split(":");
			                		try {
				                		if(gradeArr.length==2) {
				                			if(!gradeArr[0].trim().equals("")&&!gradeArr[1].trim().equals("")) {
					                			SchoolMajorYearAdmissionDetail schoolMajorYearAdmissionDetail=new SchoolMajorYearAdmissionDetail();
					                			schoolMajorYearAdmissionDetail.setAdmission(new Integer(gradeArr[1].trim()));
					                			schoolMajorYearAdmissionDetail.setGrade(new Integer(gradeArr[0].trim()));
					                			schoolMajorYearAdmissionDetail.setMajor(major);
					                			schoolMajorYearAdmissionDetail.setsCode(lastSchoolCode);
					                			schoolMajorYearAdmissionDetail.setYear(lastYear);
					                			schoolMajorYearAdmissionDetail.setBatch(lastBatch);
					                			schoolMajorYearAdmissionDetail.setMajorType(lastMajorType);
					                			
					                			if(schoolMajorYearAdmissionDetail.getGrade()>720||schoolMajorYearAdmissionDetail.getGrade()<300) {
					                				errorFlag=true;
			                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的成绩"+gradeArr[0].trim()+"错误。<br/>");
			                						continue;
					                			}
					                			
					                			schoolMajorYearAdmissionDetailList.add(schoolMajorYearAdmissionDetail);
				                			}
				                		}else {
	                						errorFlag=true;
	                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeStr+"错误。<br/>");
			                			}
			                		}catch(Exception e1) {
		                				errorFlag=true;
		    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeArr[0].trim()+";"+gradeArr[1].trim()+"错误。<br/>");
			                		}
			                	}
		                	}
	            		}//录取情况结束
	            		
	            		
	            		
	            	}//统计专业结束
            	}//excel处理结束

            	}
            }//循环处理结束
            
            
            if(errorFlag) {
            	return errorSb.toString();
            }
            
            log.info("----------begin zhinan-----"+DateUtil.now());
            
            if(schoolYearAdmissionList.size()>0) {
            	int k=0;
            	List<SchoolYearAdmission> insertSchoolYearAdmissionList=new ArrayList();
            	for(int i=0;i<schoolYearAdmissionList.size();i++) {
            		SchoolYearAdmission admission=schoolYearAdmissionList.get(i);
            		insertSchoolYearAdmissionList.add(admission);
            		k++;
            		if(k>500) {
            			schoolYearAdmissionMapper.insertSchoolYearAdmissionList(insertSchoolYearAdmissionList);
            			insertSchoolYearAdmissionList=new ArrayList();
            			k=0;
            		}
            	}
            	if(insertSchoolYearAdmissionList.size()>0) {
            		schoolYearAdmissionMapper.insertSchoolYearAdmissionList(insertSchoolYearAdmissionList);
            	}
            	
            }else {
            	return "获取不到文件数据，请确认文件内容是否正确！";
            }
            
            if(schoolMajorYearAdmissionList.size()>0) {
            	int k=0;
            	List<SchoolMajorYearAdmission> insertSchoolMajorYearAdmissionList=new ArrayList();
            	for(int i=0;i<schoolMajorYearAdmissionList.size();i++) {
            		SchoolMajorYearAdmission admission=schoolMajorYearAdmissionList.get(i);
            		insertSchoolMajorYearAdmissionList.add(admission);
            		k++;
            		if(k>500) {
            			schoolMajorYearAdmissionMapper.insertSchoolMajorYearAdmissionList(insertSchoolMajorYearAdmissionList);
            			insertSchoolMajorYearAdmissionList=new ArrayList();
            			k=0;
            		}
            	}
            	if(insertSchoolMajorYearAdmissionList.size()>0) {
            		schoolMajorYearAdmissionMapper.insertSchoolMajorYearAdmissionList(insertSchoolMajorYearAdmissionList);
            	}
            	
            	
            }
            if(schoolMajorYearAdmissionDetailList.size()>0) {
            	int k=0;
            	List<SchoolMajorYearAdmissionDetail> insertSchoolMajorYearAdmissionDetailList=new ArrayList();
            	for(int i=0;i<schoolMajorYearAdmissionDetailList.size();i++) {
            		SchoolMajorYearAdmissionDetail admission=schoolMajorYearAdmissionDetailList.get(i);
            		insertSchoolMajorYearAdmissionDetailList.add(admission);
            		k++;
            		if(k>500) {
            			schoolMajorYearAdmissionDetailMapper.insertSchoolMajorYearAdmissionDetailList(insertSchoolMajorYearAdmissionDetailList);
            			insertSchoolMajorYearAdmissionDetailList=new ArrayList();
            			k=0;
            		}
            	}
            	if(insertSchoolMajorYearAdmissionDetailList.size()>0) {
            		schoolMajorYearAdmissionDetailMapper.insertSchoolMajorYearAdmissionDetailList(insertSchoolMajorYearAdmissionDetailList);
            	}
            }
            
            if(updateSchoolYearAdmissionWsPlanList.size()>0) {
            	int k=0;
            	List<SchoolYearAdmission> updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            	for(int i=0;i<updateSchoolYearAdmissionWsPlanList.size();i++) {
            		SchoolYearAdmission admission=updateSchoolYearAdmissionWsPlanList.get(i);
            		updateSchoolYearAdmissionLgPlanList2.add(admission);
            		k++;
            		if(k>500) {
            			schoolYearAdmissionMapper.updateSchoolYearAdmissionWsTotalList(updateSchoolYearAdmissionLgPlanList2);
            			updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            			k=0;
            		}
            	}
            	if(updateSchoolYearAdmissionLgPlanList2.size()>0) {
            		schoolYearAdmissionMapper.updateSchoolYearAdmissionWsTotalList(updateSchoolYearAdmissionLgPlanList2);
            	}
            }
            
            if(updateSchoolYearAdmissionLgPlanList.size()>0) {
            	int k=0;
            	List<SchoolYearAdmission> updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            	for(int i=0;i<updateSchoolYearAdmissionLgPlanList.size();i++) {
            		SchoolYearAdmission admission=updateSchoolYearAdmissionLgPlanList.get(i);
            		updateSchoolYearAdmissionLgPlanList2.add(admission);
            		k++;
            		if(k>500) {
            			schoolYearAdmissionMapper.updateSchoolYearAdmissionTotalList(updateSchoolYearAdmissionLgPlanList2);
            			updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            			k=0;
            		}            		
            	}
            	if(updateSchoolYearAdmissionLgPlanList2.size()>0) {
            		schoolYearAdmissionMapper.updateSchoolYearAdmissionTotalList(updateSchoolYearAdmissionLgPlanList2);
            	}
            	
            }
            
            
            
            //计算学校理工类、文史类平均分和最小值
            schoolYearAdmissionList=new ArrayList();
            
            SchoolMajorYearAdmissionDetail schoolMajorYearAdmissionDetailQuery=new SchoolMajorYearAdmissionDetail();
            schoolMajorYearAdmissionDetailQuery.setYear(lastYear);
            schoolMajorYearAdmissionDetailQuery.setMajor("理工类");
            List<SchoolMajorYearAdmissionDetail> avgList1=schoolMajorYearAdmissionDetailMapper.selectSchoolYearAdmissionDetailAvgList(schoolMajorYearAdmissionDetailQuery);
            for(int i=0;i<avgList1.size();i++) {
            	SchoolMajorYearAdmissionDetail detail=avgList1.get(i);
            	String sCode=detail.getsCode();
            	String major=detail.getMajor();      
            	String majorType=detail.getMajorType();      
            	Integer avgGrade=detail.getAvggrade();
            	Integer minGrade=detail.getMingrade();
            	String batch=detail.getBatch();
            	
            	
            	SchoolYearAdmission schoolMajorYearAdmission=new SchoolYearAdmission();
        		schoolMajorYearAdmission.setsCode(sCode);
        		schoolMajorYearAdmission.setYear(lastYear);
        		schoolMajorYearAdmission.setBatch(batch);
        		schoolMajorYearAdmission.setAvgGradeLg(avgGrade);
        		schoolMajorYearAdmission.setLowGradeLg(minGrade);
        		schoolYearAdmissionList.add(schoolMajorYearAdmission);
            	
            }
            
            schoolMajorYearAdmissionDetailQuery=new SchoolMajorYearAdmissionDetail();
            schoolMajorYearAdmissionDetailQuery.setYear(lastYear);
            schoolMajorYearAdmissionDetailQuery.setMajor("文史类");
            List<SchoolMajorYearAdmissionDetail> avgListWs=schoolMajorYearAdmissionDetailMapper.selectSchoolYearAdmissionDetailAvgList(schoolMajorYearAdmissionDetailQuery);
            for(int i=0;i<avgListWs.size();i++) {
            	SchoolMajorYearAdmissionDetail detail=avgListWs.get(i);
            	String sCode=detail.getsCode();
            	String major=detail.getMajor();      
            	String majorType=detail.getMajorType();      
            	Integer avgGrade=detail.getAvggrade();
            	Integer minGrade=detail.getMingrade();
            	String batch=detail.getBatch();
            	
            	boolean lgFlag=false;
            	for(int j=0;j<schoolYearAdmissionList.size();j++) {
            		SchoolYearAdmission schoolMajorYearAdmission=schoolYearAdmissionList.get(j);
            		if(sCode.equals(schoolMajorYearAdmission.getsCode())&&batch.equals(schoolMajorYearAdmission.getBatch())) {
            			lgFlag=true;
            			schoolMajorYearAdmission.setAvgGradeWs(avgGrade);
            			schoolMajorYearAdmission.setLowGradeWs(minGrade);
            			break;
            		}
            	}
            	if(!lgFlag) {
            	
	            	SchoolYearAdmission schoolMajorYearAdmission=new SchoolYearAdmission();
	        		schoolMajorYearAdmission.setsCode(sCode);
	        		schoolMajorYearAdmission.setYear(lastYear);
	        		schoolMajorYearAdmission.setBatch(batch);
	        		schoolMajorYearAdmission.setAvgGradeWs(avgGrade);
	        		schoolMajorYearAdmission.setLowGradeWs(minGrade);
	        		schoolYearAdmissionList.add(schoolMajorYearAdmission);
            	}
            	
            }
            
            if(schoolYearAdmissionList.size()>0) {
            	int k=0;
            	List<SchoolYearAdmission> updateSchoolYearAdmissionList=new ArrayList();
            	for(int i=0;i<schoolYearAdmissionList.size();i++) {
            		SchoolYearAdmission admission=schoolYearAdmissionList.get(i);
            		updateSchoolYearAdmissionList.add(admission);
            		k++;
            		if(k>500) {
            			schoolYearAdmissionMapper.updateSchoolYearAdmissionList(updateSchoolYearAdmissionList);
            			updateSchoolYearAdmissionList=new ArrayList();
            			k=0;
            		}
            	}
            	if(updateSchoolYearAdmissionList.size()>0) {
            		schoolYearAdmissionMapper.updateSchoolYearAdmissionList(updateSchoolYearAdmissionList);
            	}
            }
            
            
            
            
            
            
            
            //计算每个专业的平均值，最小值
            schoolMajorYearAdmissionList=new ArrayList();
            schoolMajorYearAdmissionDetailQuery=new SchoolMajorYearAdmissionDetail();
            schoolMajorYearAdmissionDetailQuery.setYear(lastYear);
            List<SchoolMajorYearAdmissionDetail> avgList=schoolMajorYearAdmissionDetailMapper.selectSchoolMajorYearAdmissionDetailAvgList(schoolMajorYearAdmissionDetailQuery);
            
            
            
            for(int i=0;i<avgList.size();i++) {
            	SchoolMajorYearAdmissionDetail detail=avgList.get(i);
            	String sCode=detail.getsCode();
            	String major=detail.getMajor();      
            	String majorType=detail.getMajorType();      
            	Integer avggrade=detail.getAvggrade();
            	Integer mingrade=detail.getMingrade();
            	String batch=detail.getBatch();
            	
            	
            	SchoolMajorYearAdmission schoolMajorYearAdmission=new SchoolMajorYearAdmission();
        		schoolMajorYearAdmission.setsCode(sCode);
        		schoolMajorYearAdmission.setMajor(major);
        		schoolMajorYearAdmission.setYear(lastYear);
        		schoolMajorYearAdmission.setAvgGrade(avggrade);
        		schoolMajorYearAdmission.setLowGrade(mingrade);
        		schoolMajorYearAdmission.setBatch(batch);
        		schoolMajorYearAdmission.setMajorType(majorType);
        		schoolMajorYearAdmissionList.add(schoolMajorYearAdmission);

            }
            
            if(schoolMajorYearAdmissionList.size()>0) {
            	int k=0;
            	List<SchoolMajorYearAdmission> updateSchoolMajorYearAdmissionList=new ArrayList();
            	for(int i=0;i<schoolMajorYearAdmissionList.size();i++) {
            		SchoolMajorYearAdmission admission=schoolMajorYearAdmissionList.get(i);
            		updateSchoolMajorYearAdmissionList.add(admission);
            		k++;
            		if(k>500) {
            			schoolMajorYearAdmissionMapper.updateSchoolMajorYearAdmissionList(updateSchoolMajorYearAdmissionList);
            			updateSchoolMajorYearAdmissionList=new ArrayList();
            			k=0;
            		}
            	}
            	if(updateSchoolMajorYearAdmissionList.size()>0) {
            		schoolMajorYearAdmissionMapper.updateSchoolMajorYearAdmissionList(updateSchoolMajorYearAdmissionList);
            	}
            }
            
            
            log.info("----------end zhinan-----"+DateUtil.now());
           
            
	    } catch (IOException e) {
	        e.printStackTrace();
	        throw new RuntimeException("导入失败");
	    } finally {
	        
	    }
		/*
		List<Map<Integer, String>> listMap = EasyExcel.read(fileName).sheet().doReadSync();
        for (Map<Integer, String> data : listMap) {
            // 返回每条数据的键值对 表示所在的列 和所在列的值
            System.out.println(  new Gson().toJson(data));
        }
        */
	    return "成功";
	}
	
	
	
	
	
	
	
	
	@Override
	//@Transactional
	public String impZk(String filePath,String dataType) {
		//String fileName= "D:\\2021大专1.xls"; 
		String fileName= filePath; 
		File file = new File(fileName);
		
		boolean errorFlag=false;
        StringBuffer errorSb=new StringBuffer();
		
	    try {
	    	List<Object[]> list = new ArrayList<>();
	    	
	    	InputStream inputStream = new FileInputStream(fileName);
            Workbook workbook = WorkbookFactory.create(inputStream);
            Sheet sheet = workbook.getSheetAt(0);
            //获取sheet的行数
            int rows = sheet.getLastRowNum();
            for (int i = 0; i <= rows; i++) {
            	//获取当前行的数据
                Row row = sheet.getRow(i);
                if(row!=null) {
	                Object[] objects = new Object[row.getLastCellNum()];
	                int index = 0;
	                for (int j=0;j< row.getLastCellNum();j++) {
	                	Cell cell=row.getCell(j);
	                	if(cell==null) {
	                		objects[index] = "";
	                	}else {
		                	if (cell.getCellType().equals(CellType.NUMERIC)) {
		                		int num=(int) cell.getNumericCellValue();
		                        objects[index] = new Integer(num).toString();
		                    }else {
		                    	objects[index] = cell.getStringCellValue();
		                    }
	                	}
	                	/*
	                	if (cell.getCellType().equals(CellType.STRING)) {
	                		objects[index] = cell.getStringCellValue();
	                	}
	                	*/
	                    
	                    index++;
	                }
	                list.add(objects);
                }
            }
            
            
            //取出数据库所有的专业
            List<SMajorsZk> majorList=majorsZkMapper.selectSMajorsList(null);
            
            List<SchoolYearAdmissionZk> schoolYearAdmissionList=new ArrayList();
            List<SchoolMajorYearAdmissionZk> schoolMajorYearAdmissionList=new ArrayList();
            List<SchoolMajorYearAdmissionDetailZk> schoolMajorYearAdmissionDetailList=new ArrayList();
            
            List<SchoolYearAdmissionZk> updateSchoolYearAdmissionLgPlanList=new ArrayList();
            List<SchoolYearAdmissionZk> updateSchoolYearAdmissionWsPlanList=new ArrayList();
            
            int lastYear=0;
        	String lastSchoolCode="";
        	String lastSchoolName="";
        	String lastBatch="";
        	Long schoolYearAdmissionId=null;
        	
        	int lastPlan=-1;
        	int lastSubmit=-1;
        	int lastAdmisson=-1;
        	
        	
        	int lastPlanLg=-1;
        	int lastSubmitLg=-1;
        	int lastAdmissonLg=-1;
        	
        	int lastPlanWs=-1;
        	int lastSubmitWs=-1;
        	int lastAdmissonWs=-1;
        	
        	String lastMajor="";
        	String lastMajorType="";
            for(int i=0;i<list.size();i++) {
            	Object[] objArr=list.get(i);
            	if(objArr!=null&&objArr.length>0&&objArr[0]!=null) {
            	String obj1=objArr[0].toString();
            	obj1=obj1.trim();
            	int year=0;
            	String schoolCode="";
            	String schoolName="";
            	String batch="";
            	
            	String major="";
            	int plan=-1;
            	int submit=-1;
            	int admisson=-1;
            	String gradeStr="";
            	if(obj1!=null) {
	            	if(obj1.startsWith("年份")) {
	            		//一个新的学校
	            		try {
		            		String yearStr=obj1.substring(obj1.indexOf("年份")+3, obj1.indexOf("院校代码"));
		            		yearStr=yearStr.trim();
	            		
	            			year=new Integer(yearStr);
	            		}catch(Exception e3) {
	            			errorFlag=true;
							errorSb.append("第"+i+"行数据："+obj1+"的年份错误");
	            		}
	            		try {
		            		schoolCode=obj1.substring(obj1.indexOf("院校代码")+5, obj1.indexOf("院校名称"));
		            		schoolCode=schoolCode.trim();
		            		schoolName=obj1.substring(obj1.indexOf("院校名称")+5, obj1.indexOf("录取批次"));
		            		schoolName=schoolName.trim();
		            		batch=obj1.substring(obj1.indexOf("录取批次")+5, obj1.length());
		            		batch=batch.trim();
	            		}catch(Exception e3) {
	            			errorFlag=true;
							errorSb.append("第"+i+"行数据："+obj1+"的院校或录取批次错误");
	            		}
	            		
	            		lastMajorType="";
	            		
	            		SchoolYearAdmissionZk schoolYearAdmissionQuery=new SchoolYearAdmissionZk();
	            		schoolYearAdmissionQuery.setsCode(schoolCode);
	            		schoolYearAdmissionQuery.setYear(year);
	            		schoolYearAdmissionQuery.setBatch(batch);
	            		List<SchoolYearAdmissionZk> existList= schoolYearAdmissionZkMapper.selectSchoolYearAdmissionList(schoolYearAdmissionQuery);
	            		if(existList!=null&&existList.size()>0) {
	            			/**
	            			 * 删除相关数据，重新插入
	            			 */
	            			
	            			schoolYearAdmissionZkMapper.deleteSchoolYearAdmissionByScodeYearBatch(schoolYearAdmissionQuery);
	            			
	            			SchoolMajorYearAdmissionZk schoolMajorYearAdmission=new SchoolMajorYearAdmissionZk();
		            		schoolMajorYearAdmission.setsCode(schoolCode);
		            		schoolMajorYearAdmission.setYear(year);
		            		schoolMajorYearAdmission.setBatch(batch);
		            		schoolMajorYearAdmissionZkMapper.deleteSchoolMajorYearAdmissionByScodeYearBatch(schoolMajorYearAdmission);
		            		
		            		SchoolMajorYearAdmissionDetailZk schoolMajorYearAdmissionDetail=new SchoolMajorYearAdmissionDetailZk();
                			schoolMajorYearAdmissionDetail.setsCode(schoolCode);
                			schoolMajorYearAdmissionDetail.setYear(year);
                			schoolMajorYearAdmissionDetail.setBatch(batch);
                			schoolMajorYearAdmissionDetailZkMapper.deleteSchoolMajorYearAdmissionDetailByByScodeYearBatch(schoolMajorYearAdmissionDetail);

	            			
	            			
	            			SchoolYearAdmissionZk schoolYearAdmission=new SchoolYearAdmissionZk();
	            			schoolYearAdmission.setsCode(schoolCode);
		            		schoolYearAdmission.setYear(year);
		            		schoolYearAdmission.setBatch(batch);
		            		schoolYearAdmissionList.add(schoolYearAdmission);
		            		
		            		lastSchoolCode=schoolCode;
		            		lastSchoolName=schoolName;
		            		lastBatch=batch;
		            		lastYear=year;
	            		}else {
		            		SchoolYearAdmissionZk schoolYearAdmission=new SchoolYearAdmissionZk();
		            		schoolYearAdmission.setsCode(schoolCode);
		            		schoolYearAdmission.setYear(year);
		            		schoolYearAdmission.setBatch(batch);
		            		schoolYearAdmissionList.add(schoolYearAdmission);
		            		
		            		lastSchoolCode=schoolCode;
		            		lastSchoolName=schoolName;
		            		lastBatch=batch;
		            		lastYear=year;
	            		}
	            		
	            	}else if(obj1.startsWith("科目组及专业名称")) {
	            		//本行是标题，跳过
	            	}else {//统计专业
	            		if(!obj1.equals("")) {
	            			major=obj1.replaceAll("\\n", "");	  
	            			major=major.trim();
	            			if(major.indexOf("，")>-1) {
	            				major=major.replaceAll("，", ",");
        					}
	            			
	            			if(major.indexOf("（")>-1) {
	            				major=major.replaceAll("（", "(");
            				}
            				if(major.indexOf("）")>-1) {
            					major=major.replaceAll("）", ")");
            				}
	            			
	            			try {
		            			if(objArr[1]!=null) {
			            			String planStr=(String)objArr[1];
			            			planStr=planStr.replaceAll("\\n", "");	  
			            			planStr=planStr.trim();
			            			if(!planStr.equals("")) {
			            				plan=new Integer(planStr);
			            			}
			            		}
			            		if(objArr[2]!=null) {
			            			String submitStr=(String)objArr[2];
			            			submitStr=submitStr.replaceAll("\\n", "");	
			            			submitStr=submitStr.trim();
			            			if(!submitStr.equals("")) {
			            				submit=new Integer(submitStr);
			            			}
			            		}
			            		if(objArr[3]!=null) {
			            			String admissonStr=(String)objArr[3];
			            			admissonStr=admissonStr.replaceAll("\\n", "");	 
			            			admissonStr=admissonStr.trim();
			            			if(!admissonStr.equals("")) {
			            				admisson=new Integer(admissonStr);
			            			}
			            		}
			            		if(objArr.length>4) {
				            		if(objArr[4]!=null) {
				            			gradeStr=(String)objArr[4];
				            			gradeStr=gradeStr.replaceAll("\\n", "");	 
				            			gradeStr=gradeStr.trim();
				            		}
			            		}
	            			}catch(Exception e3) {
	            				errorFlag=true;
    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据");
    							if(objArr.length>1) {
    								errorSb.append(objArr[1]);
    							}
    							if(objArr.length>2) {
    								errorSb.append(objArr[2]);
    							}
    							if(objArr.length>3) {
    								errorSb.append(objArr[3]);
    							}
    							if(objArr.length>4) {
    								errorSb.append(objArr[4]);
    							}
    							errorSb.append("错误。<br/>");
    							continue;
	            			}
		            		
		            		if(!major.equals("")) {
		            			
		            			boolean majorFlag=false;//专业名相同标志
		            			boolean majorKHFlag=false;//专业括号名相同标志
		            			int sameMajor=0;
		            			String majorCode="";
		            			
		            			if("理工类".equals(major)) {
		            				lastMajorType="理工类";
		            				
		            				SchoolYearAdmissionZk schoolYearAdmission=new SchoolYearAdmissionZk();
				            		schoolYearAdmission.setsCode(lastSchoolCode);
				            		schoolYearAdmission.setYear(lastYear);
				            		schoolYearAdmission.setBatch(lastBatch);
				            		if(admisson==-1) {
				            			schoolYearAdmission.setAdmissionLg(0);
				            		}else {
				            			schoolYearAdmission.setAdmissionLg(admisson);
				            		}
				            		
				            		if(plan==-1) {
				            			schoolYearAdmission.setPlanLg(0);
				            		}else {
				            			schoolYearAdmission.setPlanLg(plan);
				            		}
				            		if(submit==-1) {
				            			schoolYearAdmission.setSubmitLg(0);
				            		}else {
				            			schoolYearAdmission.setSubmitLg(submit);
				            		}
				            		
				            		updateSchoolYearAdmissionLgPlanList.add(schoolYearAdmission);

		            			}else if("文史类".equals(major)) {
		            				lastMajorType="文史类";
		            				
		            				SchoolYearAdmissionZk schoolYearAdmission=new SchoolYearAdmissionZk();
				            		schoolYearAdmission.setsCode(lastSchoolCode);
				            		schoolYearAdmission.setYear(lastYear);
				            		schoolYearAdmission.setBatch(lastBatch);
				            		if(admisson==-1) {
				            			schoolYearAdmission.setAdmissionWs(0);
				            		}else {
				            			schoolYearAdmission.setAdmissionWs(admisson);
				            		}
				            		if(plan==-1) {
				            			
				            		}else {
				            			schoolYearAdmission.setPlanWs(plan);
				            		}
				            		if(submit==-1) {
				            			schoolYearAdmission.setSubmitWs(0);
				            		}else {
				            			schoolYearAdmission.setSubmitWs(submit);
				            		}
				            		
				            		updateSchoolYearAdmissionWsPlanList.add(schoolYearAdmission);
		            			}else {
		            			
			            			for(int k=0;k<majorList.size();k++) {
			            				SMajorsZk majorObj=majorList.get(k);
			            				if(majorObj.getMname().equals(major)) {//如果专业存在，不做处理
			            					majorCode=majorObj.getMcode();
			            					majorFlag=true;
			            					break;
			            				}
			            			}
			            			if(!majorFlag) {//如果专业不存在，需要插入专业表
			            				if(major.indexOf("（")>-1&&major.indexOf("）")>-1) {//判断是否包含中文括号
				            				String major1=major.substring(0, major.indexOf("（"));
				            				String major2=major.substring( major.indexOf("（")+1,major.length());
				            				
				            				for(int m=0;m<majorList.size();m++) {
					            				SMajorsZk majorObj2=majorList.get(m);
					            				String name2=majorObj2.getMname();
					            				if(name2.indexOf("(")>-1) {
					            					name2=name2.replaceAll("\\(", "（");
					            				}
					            				if(name2.indexOf(")")>-1) {
					            					name2=name2.replaceAll("\\)", "）");
					            				}
					            				if(name2.indexOf("，")>-1) {
					            					name2=name2.replaceAll("，", ",");
					            				}
					            				if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
					            					majorCode=majorObj2.getMcode();
					            					majorKHFlag=true;
					            					break;
					            				}
				            				}
				            				
				            				if(majorKHFlag) {
				            					
				            					for(int m=0;m<majorList.size();m++) {
						            				SMajorsZk majorObj2=majorList.get(m);
						            				if(majorObj2.getMname().indexOf("（")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else if(majorObj2.getMname().indexOf("(")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else {
						            					if(majorObj2.getMname().equals(major1)) {
							            					sameMajor++;
							            				}
						            				}
						            				
				            					}
				            					String code="";
				            					sameMajor++;
				            					if(sameMajor>9) {
				            						code=new Integer(sameMajor).toString();
				            					}else {
				            						code="0"+sameMajor;
				            					}
				            					SMajorsZk sMajors=new SMajorsZk();
				            					sMajors.setMname(major);
				            					if(majorCode!=null) {
				            						if(sMajors.getMname().indexOf("类")>-1) {
				            							sMajors.setMcode(majorCode+"0"+code);
				            							majorCode=majorCode+"0"+code;
				            						}else {
				            							sMajors.setMcode(majorCode+code);
				            							majorCode=majorCode+code;
				            						}
				            					}else {
				            						sMajors.setMcode(code);
				            						majorCode=code;
				            					}
				            					sMajors.setCreateTime(new Date());
					            				majorsZkMapper.insertSMajors(sMajors);
					            				
					            				majorList.add(sMajors);
				            				}
				            				
				            			}else if(major.indexOf("(")>-1&&major.indexOf(")")>-1) {//判断是否包含中文括号
				            				String major1=major.substring(0, major.indexOf("("));
				            				String major2=major.substring( major.indexOf("(")+1,major.length());
				            				
				            				for(int m=0;m<majorList.size();m++) {
					            				SMajorsZk majorObj2=majorList.get(m);
					            				String name2=majorObj2.getMname();
					            				if(name2.indexOf("（")>-1) {
					            					name2=name2.replaceAll("（", "(");
					            				}
					            				if(name2.indexOf("）")>-1) {
					            					name2=name2.replaceAll("）", ")");
					            				}
					            				if(name2.indexOf("，")>-1) {
					            					name2=name2.replaceAll("，", ",");
					            				}
					            				if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
					            					majorCode=majorObj2.getMcode();
					            					majorKHFlag=true;
					            					break;
					            				}
				            				}
				            				
				            				if(majorKHFlag) {
				            					
				            					for(int m=0;m<majorList.size();m++) {
						            				SMajorsZk majorObj2=majorList.get(m);
						            				if(majorObj2.getMname().indexOf("（")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else if(majorObj2.getMname().indexOf("(")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else {
						            					if(majorObj2.getMname().equals(major1)) {
							            					sameMajor++;
							            				}
						            				}
						            				
				            					}
				            					String code="";
				            					sameMajor++;
				            					if(sameMajor>9) {
				            						code=new Integer(sameMajor).toString();
				            					}else {
				            						code="0"+sameMajor;
				            					}
				            					SMajorsZk sMajors=new SMajorsZk();
				            					sMajors.setMname(major);
				            					if(majorCode!=null) {
				            						if(sMajors.getMname().indexOf("类")>-1) {
				            							sMajors.setMcode(majorCode+"0"+code);
				            							majorCode=majorCode+"0"+code;
				            						}else {
				            							sMajors.setMcode(majorCode+code);
				            							majorCode=majorCode+code;
				            						}
				            					}else {
				            						sMajors.setMcode(code);
				            						majorCode=code;
				            					}
				            					sMajors.setCreateTime(new Date());
					            				majorsZkMapper.insertSMajors(sMajors);
					            				
					            				majorList.add(sMajors);
				            				}
				            				
				            			} else {
				            				//后面要改
				            				errorFlag=true;
			    							errorSb.append("第"+i+"行数据"+major+"专业编码不存在。<br/>");
				            				continue;
			    							/*
				            				SMajors sMajors=new SMajors();
				            				sMajors.setMname(major);
				            				sMajors.setMcode("000000");
				            				majorsMapper.insertSMajors(sMajors);
				            				
				            				majorList.add(sMajors);
				            				*/
				            				
				            			}
			            			}
		            			}
		            			
		            			
		            		
			            		SchoolMajorYearAdmissionZk schoolMajorYearAdmission=new SchoolMajorYearAdmissionZk();
			            		schoolMajorYearAdmission.setsCode(lastSchoolCode);
			            		schoolMajorYearAdmission.setMajor(major);
			            		schoolMajorYearAdmission.setMajorCode(majorCode);
			            		schoolMajorYearAdmission.setYear(lastYear);
			            		schoolMajorYearAdmission.setMajorType(lastMajorType);
			            		schoolMajorYearAdmission.setBatch(lastBatch);
			            		if(plan!=-1) {
			            			schoolMajorYearAdmission.setPlan(plan);
			            		}
			            		if(submit!=-1) {
			            			schoolMajorYearAdmission.setSubmit(submit);
			            		}
			            		if(admisson!=-1) {
			            			schoolMajorYearAdmission.setAdmission(admisson);
			            		}
			            		
			            		if(admisson!=-1&&plan==-1) {
			            			errorFlag=true;
	    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的计划数为空");
	    							continue;
			            		}
			            		/*
			            		if(admisson>plan) {
			            			errorFlag=true;
	    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的投档数和计划数不对");
	    							continue;
			            		}
			            		*/
			            		schoolMajorYearAdmissionList.add(schoolMajorYearAdmission);
			            		
			            		lastMajor=major;
		            		}//专业不为空时判断结束
		            		
		            		//下面开始统计成绩
		            		if(major.equals("")) major=lastMajor;
		            		
		            		lastPlan=plan;
		                	lastSubmit=submit;
		                	lastAdmisson=admisson;
		                	
		                	
		                	if(gradeStr!=null&&gradeStr.length()>0) {
		                		gradeStr=gradeStr.replaceAll("\\n", "");
		                		if(gradeStr.indexOf(".")>-1) gradeStr=gradeStr.substring(0, gradeStr.indexOf("."));
		                		if(gradeStr.indexOf("．")>-1) gradeStr=gradeStr.substring(0, gradeStr.indexOf("．"));
			                	if(gradeStr.indexOf(";")>-1) {
			                		String[]  gradeStrArr=gradeStr.split(";");
			                		for(int j=0;j<gradeStrArr.length;j++) {
			                			String gradeStrj=gradeStrArr[j];
			                			gradeStrj=gradeStrj.trim();
			                			String[] gradeArr=gradeStrj.split(":");
			                			if(gradeArr.length==2) {
			                				if(!gradeArr[0].trim().equals("")&&!gradeArr[1].trim().equals("")) {
			                					try {
						                			SchoolMajorYearAdmissionDetailZk schoolMajorYearAdmissionDetail=new SchoolMajorYearAdmissionDetailZk();
						                			schoolMajorYearAdmissionDetail.setAdmission(new Integer(gradeArr[1].trim()));
						                			schoolMajorYearAdmissionDetail.setGrade(new Integer(gradeArr[0].trim()));
						                			
						                			if(schoolMajorYearAdmissionDetail.getGrade()>720||schoolMajorYearAdmissionDetail.getGrade()<180) {
						                				errorFlag=true;
				                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的成绩"+gradeArr[0].trim()+"错误。<br/>");
				                						continue;
						                			}
						                			
						                			schoolMajorYearAdmissionDetail.setMajor(major);
						                			schoolMajorYearAdmissionDetail.setsCode(lastSchoolCode);
						                			schoolMajorYearAdmissionDetail.setYear(lastYear);
						                			schoolMajorYearAdmissionDetail.setBatch(lastBatch);
						                			schoolMajorYearAdmissionDetail.setMajorType(lastMajorType);
						                			
						                			schoolMajorYearAdmissionDetailList.add(schoolMajorYearAdmissionDetail);
			                					}catch(Exception e2) {
			                						System.out.println("-------------------ee:"+gradeStrj+",lastMajor:"+major+",lastSchoolCode:"+lastSchoolCode);
			                						errorFlag=true;
			                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeArr[0].trim()+";"+gradeArr[1].trim()+"错误。<br/>");
			                					}
			                				}
			                			}else {
			                				System.out.println("-------------------ee:"+gradeStrj);
			                				errorFlag=true;
			    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeStrj+"错误。<br/>");
			                			}
			                		}
			                	}else {
			                		String[] gradeArr=gradeStr.split(":");			
			                		try {
				                		if(gradeArr.length==2) {
				                			if(!gradeArr[0].trim().equals("")&&!gradeArr[1].trim().equals("")) {
					                			SchoolMajorYearAdmissionDetailZk schoolMajorYearAdmissionDetail=new SchoolMajorYearAdmissionDetailZk();
					                			schoolMajorYearAdmissionDetail.setAdmission(new Integer(gradeArr[1].trim()));
					                			schoolMajorYearAdmissionDetail.setGrade(new Integer(gradeArr[0].trim()));
					                			
					                			if(schoolMajorYearAdmissionDetail.getGrade()>720||schoolMajorYearAdmissionDetail.getGrade()<180) {
					                				errorFlag=true;
			                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的成绩"+gradeArr[0].trim()+"错误。<br/>");
			                						continue;
					                			}
					                			
					                			schoolMajorYearAdmissionDetail.setMajor(major);
					                			schoolMajorYearAdmissionDetail.setsCode(lastSchoolCode);
					                			schoolMajorYearAdmissionDetail.setYear(lastYear);
					                			schoolMajorYearAdmissionDetail.setBatch(lastBatch);
					                			schoolMajorYearAdmissionDetail.setMajorType(lastMajorType);
					                			
					                			schoolMajorYearAdmissionDetailList.add(schoolMajorYearAdmissionDetail);
				                			}
				                		}else {
	                						errorFlag=true;
	                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeStr+"错误。<br/>");
			                			}
			                		}catch(Exception e1) {
		                				errorFlag=true;
		    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeArr[0].trim()+";"+gradeArr[1].trim()+"错误。<br/>");
			                		}
			                	}
		                	}
		            		
	            		}else {//这一行对象是空的
	            			
	            			if(major.equals("")) major=lastMajor;
	            			
	            			if(objArr.length>4) {
		            			if(objArr[4]!=null) {
			            			gradeStr=(String)objArr[4];
			            			gradeStr=gradeStr.replaceAll("\\n", "");	 
			            			gradeStr=gradeStr.trim();
			            		}
	            			}
	            			
	            			if(gradeStr!=null&&gradeStr.length()>0) {
	            				gradeStr=gradeStr.replaceAll("\\n", "");
	            				gradeStr=gradeStr.trim();
		                		if(gradeStr.indexOf(".")>-1) gradeStr=gradeStr.substring(0, gradeStr.indexOf("."));
		                		if(gradeStr.indexOf("．")>-1) gradeStr=gradeStr.substring(0, gradeStr.indexOf("．"));
			                	if(gradeStr.indexOf(";")>-1) {
			                		String[]  gradeStrArr=gradeStr.split(";");
			                		
			                		for(int j=0;j<gradeStrArr.length;j++) {
			                			String gradeStrj=gradeStrArr[j];
			                			gradeStrj=gradeStrj.trim();
			                			String[] gradeArr=gradeStrj.split(":");
			                			if(gradeArr.length==2) {
			                				try {
				                				if(!gradeArr[0].trim().equals("")&&!gradeArr[1].trim().equals("")) {
						                			SchoolMajorYearAdmissionDetailZk schoolMajorYearAdmissionDetail=new SchoolMajorYearAdmissionDetailZk();
						                			schoolMajorYearAdmissionDetail.setAdmission(new Integer(gradeArr[1].trim()));
						                			schoolMajorYearAdmissionDetail.setGrade(new Integer(gradeArr[0].trim()));
						                			schoolMajorYearAdmissionDetail.setMajor(major);
						                			schoolMajorYearAdmissionDetail.setsCode(lastSchoolCode);
						                			schoolMajorYearAdmissionDetail.setYear(lastYear);
						                			schoolMajorYearAdmissionDetail.setBatch(lastBatch);
						                			schoolMajorYearAdmissionDetail.setMajorType(lastMajorType);
						                			
						                			if(schoolMajorYearAdmissionDetail.getGrade()>720||schoolMajorYearAdmissionDetail.getGrade()<180) {
						                				errorFlag=true;
				                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的成绩"+gradeArr[0].trim()+"错误。<br/>");
				                						continue;
						                			}
						                			
						                			schoolMajorYearAdmissionDetailList.add(schoolMajorYearAdmissionDetail);
				                				}
			                				}catch(Exception e2) {
		                						System.out.println("-------------------ee:"+gradeStrj+",lastMajor:"+major+",lastSchoolCode:"+lastSchoolCode);
		                						errorFlag=true;
		                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeArr[0].trim()+";"+gradeArr[1].trim()+"错误。<br/>");
		                					}
			                			}else {
			                				System.out.println("-------------------ee:"+gradeStrj+",lastMajor:"+major+",lastSchoolCode:"+lastSchoolCode);
			                				errorFlag=true;
	                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeStr+"错误。<br/>");
			                			}
			                		}
			                	}else {
			                		String[] gradeArr=gradeStr.split(":");
			                		try {
				                		if(gradeArr.length==2) {
				                			if(!gradeArr[0].trim().equals("")&&!gradeArr[1].trim().equals("")) {
					                			SchoolMajorYearAdmissionDetailZk schoolMajorYearAdmissionDetail=new SchoolMajorYearAdmissionDetailZk();
					                			schoolMajorYearAdmissionDetail.setAdmission(new Integer(gradeArr[1].trim()));
					                			schoolMajorYearAdmissionDetail.setGrade(new Integer(gradeArr[0].trim()));
					                			schoolMajorYearAdmissionDetail.setMajor(major);
					                			schoolMajorYearAdmissionDetail.setsCode(lastSchoolCode);
					                			schoolMajorYearAdmissionDetail.setYear(lastYear);
					                			schoolMajorYearAdmissionDetail.setBatch(lastBatch);
					                			schoolMajorYearAdmissionDetail.setMajorType(lastMajorType);
					                			
					                			if(schoolMajorYearAdmissionDetail.getGrade()>720||schoolMajorYearAdmissionDetail.getGrade()<180) {
					                				errorFlag=true;
			                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的成绩"+gradeArr[0].trim()+"错误。<br/>");
			                						continue;
					                			}
					                			
					                			schoolMajorYearAdmissionDetailList.add(schoolMajorYearAdmissionDetail);
				                			}
				                		}else {
	                						errorFlag=true;
	                						errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeStr+"错误。<br/>");
			                			}
			                		}catch(Exception e1) {
		                				errorFlag=true;
		    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据"+gradeArr[0].trim()+";"+gradeArr[1].trim()+"错误。<br/>");
			                		}
			                	}
		                	}
	            		}//录取情况结束
	            		
	            		
	            		
	            	}//统计专业结束
            	}//excel处理结束

            	}
            }//循环处理结束
            
            
            if(errorFlag) {
            	return errorSb.toString();
            }
            
            log.info("----------begin zhinan-----"+DateUtil.now());
            
            if(schoolYearAdmissionList.size()>0) {
            	int k=0;
            	List<SchoolYearAdmissionZk> insertSchoolYearAdmissionList=new ArrayList();
            	for(int i=0;i<schoolYearAdmissionList.size();i++) {
            		SchoolYearAdmissionZk admission=schoolYearAdmissionList.get(i);
            		insertSchoolYearAdmissionList.add(admission);
            		k++;
            		if(k>500) {
            			schoolYearAdmissionZkMapper.insertSchoolYearAdmissionList(insertSchoolYearAdmissionList);
            			insertSchoolYearAdmissionList=new ArrayList();
            			k=0;
            		}
            	}
            	if(insertSchoolYearAdmissionList.size()>0) {
            		schoolYearAdmissionZkMapper.insertSchoolYearAdmissionList(insertSchoolYearAdmissionList);
            	}
            	
            }else {
            	return "获取不到文件数据，请确认文件内容是否正确！";
            }
            
            if(schoolMajorYearAdmissionList.size()>0) {
            	int k=0;
            	List<SchoolMajorYearAdmissionZk> insertSchoolMajorYearAdmissionList=new ArrayList();
            	for(int i=0;i<schoolMajorYearAdmissionList.size();i++) {
            		SchoolMajorYearAdmissionZk admission=schoolMajorYearAdmissionList.get(i);
            		insertSchoolMajorYearAdmissionList.add(admission);
            		k++;
            		if(k>500) {
            			schoolMajorYearAdmissionZkMapper.insertSchoolMajorYearAdmissionList(insertSchoolMajorYearAdmissionList);
            			insertSchoolMajorYearAdmissionList=new ArrayList();
            			k=0;
            		}
            	}
            	if(insertSchoolMajorYearAdmissionList.size()>0) {
            		schoolMajorYearAdmissionZkMapper.insertSchoolMajorYearAdmissionList(insertSchoolMajorYearAdmissionList);
            	}
            	
            	
            }
            if(schoolMajorYearAdmissionDetailList.size()>0) {
            	int k=0;
            	List<SchoolMajorYearAdmissionDetailZk> insertSchoolMajorYearAdmissionDetailList=new ArrayList();
            	for(int i=0;i<schoolMajorYearAdmissionDetailList.size();i++) {
            		SchoolMajorYearAdmissionDetailZk admission=schoolMajorYearAdmissionDetailList.get(i);
            		insertSchoolMajorYearAdmissionDetailList.add(admission);
            		k++;
            		if(k>500) {
            			schoolMajorYearAdmissionDetailZkMapper.insertSchoolMajorYearAdmissionDetailList(insertSchoolMajorYearAdmissionDetailList);
            			insertSchoolMajorYearAdmissionDetailList=new ArrayList();
            			k=0;
            		}
            	}
            	if(insertSchoolMajorYearAdmissionDetailList.size()>0) {
            		schoolMajorYearAdmissionDetailZkMapper.insertSchoolMajorYearAdmissionDetailList(insertSchoolMajorYearAdmissionDetailList);
            	}
            }
            
            if(updateSchoolYearAdmissionWsPlanList.size()>0) {
            	int k=0;
            	List<SchoolYearAdmissionZk> updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            	for(int i=0;i<updateSchoolYearAdmissionWsPlanList.size();i++) {
            		SchoolYearAdmissionZk admission=updateSchoolYearAdmissionWsPlanList.get(i);
            		updateSchoolYearAdmissionLgPlanList2.add(admission);
            		k++;
            		if(k>500) {
            			schoolYearAdmissionZkMapper.updateSchoolYearAdmissionWsTotalList(updateSchoolYearAdmissionLgPlanList2);
            			updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            			k=0;
            		}
            	}
            	if(updateSchoolYearAdmissionLgPlanList2.size()>0) {
            		schoolYearAdmissionZkMapper.updateSchoolYearAdmissionWsTotalList(updateSchoolYearAdmissionLgPlanList2);
            	}
            }
            
            if(updateSchoolYearAdmissionLgPlanList.size()>0) {
            	int k=0;
            	List<SchoolYearAdmissionZk> updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            	for(int i=0;i<updateSchoolYearAdmissionLgPlanList.size();i++) {
            		SchoolYearAdmissionZk admission=updateSchoolYearAdmissionLgPlanList.get(i);
            		updateSchoolYearAdmissionLgPlanList2.add(admission);
            		k++;
            		if(k>500) {
            			schoolYearAdmissionZkMapper.updateSchoolYearAdmissionTotalList(updateSchoolYearAdmissionLgPlanList2);
            			updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            			k=0;
            		}            		
            	}
            	if(updateSchoolYearAdmissionLgPlanList2.size()>0) {
            		schoolYearAdmissionZkMapper.updateSchoolYearAdmissionTotalList(updateSchoolYearAdmissionLgPlanList2);
            	}
            	
            }
            
            
            
            //计算学校理工类、文史类平均分和最小值
            schoolYearAdmissionList=new ArrayList();
            
            SchoolMajorYearAdmissionDetailZk schoolMajorYearAdmissionDetailQuery=new SchoolMajorYearAdmissionDetailZk();
            schoolMajorYearAdmissionDetailQuery.setYear(lastYear);
            schoolMajorYearAdmissionDetailQuery.setMajor("理工类");
            List<SchoolMajorYearAdmissionDetailZk> avgList1=schoolMajorYearAdmissionDetailZkMapper.selectSchoolYearAdmissionDetailAvgList(schoolMajorYearAdmissionDetailQuery);
            for(int i=0;i<avgList1.size();i++) {
            	SchoolMajorYearAdmissionDetailZk detail=avgList1.get(i);
            	String sCode=detail.getsCode();
            	String major=detail.getMajor();      
            	String majorType=detail.getMajorType();      
            	Integer avgGrade=detail.getAvggrade();
            	Integer minGrade=detail.getMingrade();
            	String batch=detail.getBatch();
            	
            	
            	SchoolYearAdmissionZk schoolMajorYearAdmission=new SchoolYearAdmissionZk();
        		schoolMajorYearAdmission.setsCode(sCode);
        		schoolMajorYearAdmission.setYear(lastYear);
        		schoolMajorYearAdmission.setBatch(batch);
        		schoolMajorYearAdmission.setAvgGradeLg(avgGrade);
        		schoolMajorYearAdmission.setLowGradeLg(minGrade);
        		schoolYearAdmissionList.add(schoolMajorYearAdmission);
            	
            }
            
            schoolMajorYearAdmissionDetailQuery=new SchoolMajorYearAdmissionDetailZk();
            schoolMajorYearAdmissionDetailQuery.setYear(lastYear);
            schoolMajorYearAdmissionDetailQuery.setMajor("文史类");
            List<SchoolMajorYearAdmissionDetailZk> avgListWs=schoolMajorYearAdmissionDetailZkMapper.selectSchoolYearAdmissionDetailAvgList(schoolMajorYearAdmissionDetailQuery);
            for(int i=0;i<avgListWs.size();i++) {
            	SchoolMajorYearAdmissionDetailZk detail=avgListWs.get(i);
            	String sCode=detail.getsCode();
            	String major=detail.getMajor();      
            	String majorType=detail.getMajorType();      
            	Integer avgGrade=detail.getAvggrade();
            	Integer minGrade=detail.getMingrade();
            	String batch=detail.getBatch();
            	
            	boolean lgFlag=false;
            	for(int j=0;j<schoolYearAdmissionList.size();j++) {
            		SchoolYearAdmissionZk schoolMajorYearAdmission=schoolYearAdmissionList.get(j);
            		if(sCode.equals(schoolMajorYearAdmission.getsCode())&&batch.equals(schoolMajorYearAdmission.getBatch())) {
            			lgFlag=true;
            			schoolMajorYearAdmission.setAvgGradeWs(avgGrade);
            			schoolMajorYearAdmission.setLowGradeWs(minGrade);
            			break;
            		}
            	}
            	if(!lgFlag) {
            	
	            	SchoolYearAdmissionZk schoolMajorYearAdmission=new SchoolYearAdmissionZk();
	        		schoolMajorYearAdmission.setsCode(sCode);
	        		schoolMajorYearAdmission.setYear(lastYear);
	        		schoolMajorYearAdmission.setBatch(batch);
	        		schoolMajorYearAdmission.setAvgGradeWs(avgGrade);
	        		schoolMajorYearAdmission.setLowGradeWs(minGrade);
	        		schoolYearAdmissionList.add(schoolMajorYearAdmission);
            	}
            	
            }
            
            if(schoolYearAdmissionList.size()>0) {
            	int k=0;
            	List<SchoolYearAdmissionZk> updateSchoolYearAdmissionList=new ArrayList();
            	for(int i=0;i<schoolYearAdmissionList.size();i++) {
            		SchoolYearAdmissionZk admission=schoolYearAdmissionList.get(i);
            		updateSchoolYearAdmissionList.add(admission);
            		k++;
            		if(k>500) {
            			schoolYearAdmissionZkMapper.updateSchoolYearAdmissionList(updateSchoolYearAdmissionList);
            			updateSchoolYearAdmissionList=new ArrayList();
            			k=0;
            		}
            	}
            	if(updateSchoolYearAdmissionList.size()>0) {
            		schoolYearAdmissionZkMapper.updateSchoolYearAdmissionList(updateSchoolYearAdmissionList);
            	}
            }
            
            
            
            
            
            
            
            //计算每个专业的平均值，最小值
            schoolMajorYearAdmissionList=new ArrayList();
            schoolMajorYearAdmissionDetailQuery=new SchoolMajorYearAdmissionDetailZk();
            schoolMajorYearAdmissionDetailQuery.setYear(lastYear);
            List<SchoolMajorYearAdmissionDetailZk> avgList=schoolMajorYearAdmissionDetailZkMapper.selectSchoolMajorYearAdmissionDetailAvgList(schoolMajorYearAdmissionDetailQuery);
            
            
            
            for(int i=0;i<avgList.size();i++) {
            	SchoolMajorYearAdmissionDetailZk detail=avgList.get(i);
            	String sCode=detail.getsCode();
            	String major=detail.getMajor();      
            	String majorType=detail.getMajorType();      
            	Integer avggrade=detail.getAvggrade();
            	Integer mingrade=detail.getMingrade();
            	String batch=detail.getBatch();
            	
            	
            	SchoolMajorYearAdmissionZk schoolMajorYearAdmission=new SchoolMajorYearAdmissionZk();
        		schoolMajorYearAdmission.setsCode(sCode);
        		schoolMajorYearAdmission.setMajor(major);
        		schoolMajorYearAdmission.setYear(lastYear);
        		schoolMajorYearAdmission.setAvgGrade(avggrade);
        		schoolMajorYearAdmission.setLowGrade(mingrade);
        		schoolMajorYearAdmission.setBatch(batch);
        		schoolMajorYearAdmission.setMajorType(majorType);
        		schoolMajorYearAdmissionList.add(schoolMajorYearAdmission);

            }
            
            if(schoolMajorYearAdmissionList.size()>0) {
            	int k=0;
            	List<SchoolMajorYearAdmissionZk> updateSchoolMajorYearAdmissionList=new ArrayList();
            	for(int i=0;i<schoolMajorYearAdmissionList.size();i++) {
            		SchoolMajorYearAdmissionZk admission=schoolMajorYearAdmissionList.get(i);
            		updateSchoolMajorYearAdmissionList.add(admission);
            		k++;
            		if(k>500) {
            			schoolMajorYearAdmissionZkMapper.updateSchoolMajorYearAdmissionList(updateSchoolMajorYearAdmissionList);
            			updateSchoolMajorYearAdmissionList=new ArrayList();
            			k=0;
            		}
            	}
            	if(updateSchoolMajorYearAdmissionList.size()>0) {
            		schoolMajorYearAdmissionZkMapper.updateSchoolMajorYearAdmissionList(updateSchoolMajorYearAdmissionList);
            	}
            }
            
            
            log.info("----------end zhinan-----"+DateUtil.now());
           
            
	    } catch (IOException e) {
	        e.printStackTrace();
	        throw new RuntimeException("导入失败");
	    } finally {
	        
	    }
		/*
		List<Map<Integer, String>> listMap = EasyExcel.read(fileName).sheet().doReadSync();
        for (Map<Integer, String> data : listMap) {
            // 返回每条数据的键值对 表示所在的列 和所在列的值
            System.out.println(  new Gson().toJson(data));
        }
        */
	    return "成功";
	}
	
	
	
	
	
	@Override
	//@Transactional
	public String impZk2023(String filePath,String dataType) {
		//String fileName= "D:\\23大专(修改好)22.xls"; 
		String fileName= filePath; 
		File file = new File(fileName);
		
		boolean errorFlag=false;
        StringBuffer errorSb=new StringBuffer();
		
	    try {
	    	List<Object[]> list = new ArrayList<>();
	    	
	    	InputStream inputStream = new FileInputStream(fileName);
            Workbook workbook = WorkbookFactory.create(inputStream);
            Sheet sheet = workbook.getSheetAt(0);
            //获取sheet的行数
            int rows = sheet.getLastRowNum();
            for (int i = 0; i <= rows; i++) {
            	//获取当前行的数据
                Row row = sheet.getRow(i);
                if(row!=null) {
	                Object[] objects = new Object[row.getLastCellNum()];
	                int index = 0;
	                for (int j=0;j< row.getLastCellNum();j++) {
	                	Cell cell=row.getCell(j);
	                	if(cell==null) {
	                		objects[index] = "";
	                	}else {
		                	if (cell.getCellType().equals(CellType.NUMERIC)) {
		                		int num=(int) cell.getNumericCellValue();
		                        objects[index] = new Integer(num).toString();
		                    }else {
		                    	objects[index] = cell.getStringCellValue();
		                    }
	                	}
	                	/*
	                	if (cell.getCellType().equals(CellType.STRING)) {
	                		objects[index] = cell.getStringCellValue();
	                	}
	                	*/
	                    
	                    index++;
	                }
	                list.add(objects);
                }
            }
            
            
            //取出数据库所有的专业
            List<SMajorsZk> majorList=majorsZkMapper.selectSMajorsList(null);
            
            List<SchoolYearAdmissionZk> schoolYearAdmissionList=new ArrayList();
            List<SchoolMajorYearAdmissionZk> schoolMajorYearAdmissionList=new ArrayList();
            
            
            List<SchoolYearAdmissionZk> updateSchoolYearAdmissionLgPlanList=new ArrayList();
            List<SchoolYearAdmissionZk> updateSchoolYearAdmissionWsPlanList=new ArrayList();
            
            int lastYear=0;
        	String lastSchoolCode="";
        	String lastSchoolName="";
        	String lastBatch="";
        	Long schoolYearAdmissionId=null;
        	
        	int lastPlan=-1;
        	int lastSubmit=-1;
        	int lastAdmisson=-1;
        	
        	
        	int lastPlanLg=-1;
        	int lastSubmitLg=-1;
        	int lastAdmissonLg=-1;
        	
        	int lastPlanWs=-1;
        	int lastSubmitWs=-1;
        	int lastAdmissonWs=-1;
        	String batch="";
        	String lastMajor="";
        	String lastMajorType="";
            for(int i=0;i<list.size();i++) {
            	Object[] objArr=list.get(i);
            	if(objArr!=null&&objArr.length>0&&objArr[0]!=null) {
            	String obj1=objArr[0].toString();
            	obj1=obj1.trim();
            	int year=0;
            	String schoolCode="";
            	String schoolName="";
            	
            	
            	String major="";
            	int plan=-1;
            	int heightGrade=0;
            	int avgGrade=0;
            	int lowGrade=0;
            	
            	int admisson=-1;
            	String gradeStr="";
            	if(obj1!=null) {
	            	if(obj1.startsWith("院校代码")) {
	            		//一个新的学校
		            	String yearStr="2023";
	            		
	            		year=2023;
	            		
	            		try {
		            		schoolCode=obj1.substring(obj1.indexOf("院校代码")+5, obj1.indexOf("院校名称"));
		            		schoolCode=schoolCode.trim();
		            		schoolName=obj1.substring(obj1.indexOf("院校名称")+5, obj1.length());
		            		schoolName=schoolName.trim();
		            		batch="高职高专普通批";
	            		}catch(Exception e3) {
	            			errorFlag=true;
							errorSb.append("第"+i+"行数据："+obj1+"的院校或录取批次错误");
	            		}
	            		
	            		lastMajorType="";
	            		
	            		SchoolYearAdmissionZk schoolYearAdmissionQuery=new SchoolYearAdmissionZk();
	            		schoolYearAdmissionQuery.setsCode(schoolCode);
	            		schoolYearAdmissionQuery.setYear(year);
	            		schoolYearAdmissionQuery.setBatch(batch);
	            		List<SchoolYearAdmissionZk> existList= schoolYearAdmissionZkMapper.selectSchoolYearAdmissionList(schoolYearAdmissionQuery);
	            		if(existList!=null&&existList.size()>0) {
	            			/**
	            			 * 删除相关数据，重新插入
	            			 */
	            			
	            			schoolYearAdmissionZkMapper.deleteSchoolYearAdmissionByScodeYearBatch(schoolYearAdmissionQuery);
	            			
	            			SchoolMajorYearAdmissionZk schoolMajorYearAdmission=new SchoolMajorYearAdmissionZk();
		            		schoolMajorYearAdmission.setsCode(schoolCode);
		            		schoolMajorYearAdmission.setYear(year);
		            		schoolMajorYearAdmission.setBatch(batch);
		            		schoolMajorYearAdmissionZkMapper.deleteSchoolMajorYearAdmissionByScodeYearBatch(schoolMajorYearAdmission);
		            		
		            		

	            			
	            			
	            			SchoolYearAdmissionZk schoolYearAdmission=new SchoolYearAdmissionZk();
	            			schoolYearAdmission.setsCode(schoolCode);
		            		schoolYearAdmission.setYear(year);
		            		schoolYearAdmission.setBatch(batch);
		            		schoolYearAdmissionList.add(schoolYearAdmission);
		            		
		            		lastSchoolCode=schoolCode;
		            		lastSchoolName=schoolName;
		            		lastBatch=batch;
		            		lastYear=year;
	            		}else {
		            		SchoolYearAdmissionZk schoolYearAdmission=new SchoolYearAdmissionZk();
		            		schoolYearAdmission.setsCode(schoolCode);
		            		schoolYearAdmission.setYear(year);
		            		schoolYearAdmission.setBatch(batch);
		            		schoolYearAdmissionList.add(schoolYearAdmission);
		            		
		            		lastSchoolCode=schoolCode;
		            		lastSchoolName=schoolName;
		            		lastBatch=batch;
		            		lastYear=year;
	            		}
	            		
	            	}else if(obj1.startsWith("科目组及专业名称")) {
	            		//本行是标题，跳过
	            	}else if(obj1.startsWith("高职高专普通批")) {
	            		//本行是标题，跳过
	            	}else {//统计专业
	            		if(!obj1.equals("")) {
	            			major=obj1.replaceAll("\\n", "");	  
	            			major=major.trim();
	            			if(major.indexOf("，")>-1) {
	            				major=major.replaceAll("，", ",");
        					}
	            			
	            			if(major.indexOf("（")>-1) {
	            				major=major.replaceAll("（", "(");
            				}
            				if(major.indexOf("）")>-1) {
            					major=major.replaceAll("）", ")");
            				}
	            			
	            			try {
		            			if(objArr[1]!=null) {
			            			String planStr=(String)objArr[1];
			            			planStr=planStr.replaceAll("\\n", "");	  
			            			planStr=planStr.trim();
			            			if(!planStr.equals("")) {
			            				plan=new Integer(planStr);
			            			}
			            		}
			            		
			            		if(objArr[2]!=null) {
			            			String admissonStr=(String)objArr[2];
			            			admissonStr=admissonStr.replaceAll("\\n", "");	 
			            			admissonStr=admissonStr.trim();
			            			if(!admissonStr.equals("")) {
			            				admisson=new Integer(admissonStr);
			            			}
			            		}
			            		if(objArr[3]!=null) {
			            			String heightGradeStr=(String)objArr[3];
			            			heightGradeStr=heightGradeStr.replaceAll("\\n", "");	
			            			heightGradeStr=heightGradeStr.trim();
			            			if(!heightGradeStr.equals("")) {
			            				heightGrade=new Integer(heightGradeStr);
			            			}
			            		}
			            		
			            		if(objArr[4]!=null) {
			            			String avgGradeStr=(String)objArr[4];
			            			avgGradeStr=avgGradeStr.replaceAll("\\n", "");	
			            			avgGradeStr=avgGradeStr.trim();
			            			if(!avgGradeStr.equals("")) {
			            				avgGrade=new Integer(avgGradeStr);
			            			}
			            		}
			            		
			            		if(objArr[5]!=null) {
			            			String lowGradeStr=(String)objArr[5];
			            			lowGradeStr=lowGradeStr.replaceAll("\\n", "");	
			            			lowGradeStr=lowGradeStr.trim();
			            			if(!lowGradeStr.equals("")) {
			            				lowGrade=new Integer(lowGradeStr);
			            			}
			            		}
			            		
			            		
			            		
	            			}catch(Exception e3) {
	            				errorFlag=true;
    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据");
    							if(objArr.length>1) {
    								errorSb.append(objArr[1]);
    							}
    							if(objArr.length>2) {
    								errorSb.append(objArr[2]);
    							}
    							if(objArr.length>3) {
    								errorSb.append(objArr[3]);
    							}
    							if(objArr.length>4) {
    								errorSb.append(objArr[4]);
    							}
    							
    							if(objArr.length>5) {
    								errorSb.append(objArr[5]);
    							}
    							errorSb.append("错误。<br/>");
    							continue;
	            			}
		            		
		            		if(!major.equals("")) {
		            			
		            			boolean majorFlag=false;//专业名相同标志
		            			boolean majorKHFlag=false;//专业括号名相同标志
		            			int sameMajor=0;
		            			String majorCode="";
		            			
		            			if("理工类".equals(major)) {
		            				lastMajorType="理工类";
		            				
		            				SchoolYearAdmissionZk schoolYearAdmission=new SchoolYearAdmissionZk();
				            		schoolYearAdmission.setsCode(lastSchoolCode);
				            		schoolYearAdmission.setYear(lastYear);
				            		schoolYearAdmission.setBatch(lastBatch);
				            		if(admisson==-1) {
				            			schoolYearAdmission.setAdmissionLg(0);
				            		}else {
				            			schoolYearAdmission.setAdmissionLg(admisson);
				            		}
				            		
				            		if(plan==-1) {
				            			schoolYearAdmission.setPlanLg(0);
				            		}else {
				            			schoolYearAdmission.setPlanLg(plan);
				            		}

				            		
				            		
				            		updateSchoolYearAdmissionLgPlanList.add(schoolYearAdmission);

		            			}else if("文史类".equals(major)) {
		            				lastMajorType="文史类";
		            				
		            				SchoolYearAdmissionZk schoolYearAdmission=new SchoolYearAdmissionZk();
				            		schoolYearAdmission.setsCode(lastSchoolCode);
				            		schoolYearAdmission.setYear(lastYear);
				            		schoolYearAdmission.setBatch(lastBatch);
				            		if(admisson==-1) {
				            			schoolYearAdmission.setAdmissionWs(0);
				            		}else {
				            			schoolYearAdmission.setAdmissionWs(admisson);
				            		}
				            		if(plan==-1) {
				            			
				            		}else {
				            			schoolYearAdmission.setPlanWs(plan);
				            		}
				            		
				            		
				            		updateSchoolYearAdmissionWsPlanList.add(schoolYearAdmission);
		            			}else {
		            			
			            			for(int k=0;k<majorList.size();k++) {
			            				SMajorsZk majorObj=majorList.get(k);
			            				if(majorObj.getMname().equals(major)) {//如果专业存在，不做处理
			            					majorCode=majorObj.getMcode();
			            					majorFlag=true;
			            					break;
			            				}
			            			}
			            			if(!majorFlag) {//如果专业不存在，需要插入专业表
			            				if(major.indexOf("（")>-1&&major.indexOf("）")>-1) {//判断是否包含中文括号
				            				String major1=major.substring(0, major.indexOf("（"));
				            				String major2=major.substring( major.indexOf("（")+1,major.length());
				            				
				            				for(int m=0;m<majorList.size();m++) {
					            				SMajorsZk majorObj2=majorList.get(m);
					            				String name2=majorObj2.getMname();
					            				if(name2.indexOf("(")>-1) {
					            					name2=name2.replaceAll("\\(", "（");
					            				}
					            				if(name2.indexOf(")")>-1) {
					            					name2=name2.replaceAll("\\)", "）");
					            				}
					            				if(name2.indexOf("，")>-1) {
					            					name2=name2.replaceAll("，", ",");
					            				}
					            				if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
					            					majorCode=majorObj2.getMcode();
					            					majorKHFlag=true;
					            					break;
					            				}
				            				}
				            				
				            				if(majorKHFlag) {
				            					
				            					for(int m=0;m<majorList.size();m++) {
						            				SMajorsZk majorObj2=majorList.get(m);
						            				if(majorObj2.getMname().indexOf("（")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else if(majorObj2.getMname().indexOf("(")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else {
						            					if(majorObj2.getMname().equals(major1)) {
							            					sameMajor++;
							            				}
						            				}
						            				
				            					}
				            					String code="";
				            					sameMajor++;
				            					if(sameMajor>9) {
				            						code=new Integer(sameMajor).toString();
				            					}else {
				            						code="0"+sameMajor;
				            					}
				            					SMajorsZk sMajors=new SMajorsZk();
				            					sMajors.setMname(major);
				            					if(majorCode!=null) {
				            						if(sMajors.getMname().indexOf("类")>-1) {
				            							sMajors.setMcode(majorCode+"0"+code);
				            							majorCode=majorCode+"0"+code;
				            						}else {
				            							sMajors.setMcode(majorCode+code);
				            							majorCode=majorCode+code;
				            						}
				            					}else {
				            						sMajors.setMcode(code);
				            						majorCode=code;
				            					}
				            					sMajors.setCreateTime(new Date());
					            				majorsZkMapper.insertSMajors(sMajors);
					            				
					            				majorList.add(sMajors);
				            				}
				            				
				            			}else if(major.indexOf("(")>-1&&major.indexOf(")")>-1) {//判断是否包含中文括号
				            				String major1=major.substring(0, major.indexOf("("));
				            				String major2=major.substring( major.indexOf("(")+1,major.length());
				            				
				            				for(int m=0;m<majorList.size();m++) {
					            				SMajorsZk majorObj2=majorList.get(m);
					            				String name2=majorObj2.getMname();
					            				if(name2.indexOf("（")>-1) {
					            					name2=name2.replaceAll("（", "(");
					            				}
					            				if(name2.indexOf("）")>-1) {
					            					name2=name2.replaceAll("）", ")");
					            				}
					            				if(name2.indexOf("，")>-1) {
					            					name2=name2.replaceAll("，", ",");
					            				}
					            				if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
					            					majorCode=majorObj2.getMcode();
					            					majorKHFlag=true;
					            					break;
					            				}
				            				}
				            				
				            				if(majorKHFlag) {
				            					
				            					for(int m=0;m<majorList.size();m++) {
						            				SMajorsZk majorObj2=majorList.get(m);
						            				if(majorObj2.getMname().indexOf("（")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else if(majorObj2.getMname().indexOf("(")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else {
						            					if(majorObj2.getMname().equals(major1)) {
							            					sameMajor++;
							            				}
						            				}
						            				
				            					}
				            					String code="";
				            					sameMajor++;
				            					if(sameMajor>9) {
				            						code=new Integer(sameMajor).toString();
				            					}else {
				            						code="0"+sameMajor;
				            					}
				            					SMajorsZk sMajors=new SMajorsZk();
				            					sMajors.setMname(major);
				            					if(majorCode!=null) {
				            						if(sMajors.getMname().indexOf("类")>-1) {
				            							sMajors.setMcode(majorCode+"0"+code);
				            							majorCode=majorCode+"0"+code;
				            						}else {
				            							sMajors.setMcode(majorCode+code);
				            							majorCode=majorCode+code;
				            						}
				            					}else {
				            						sMajors.setMcode(code);
				            						majorCode=code;
				            					}
				            					sMajors.setCreateTime(new Date());
					            				majorsZkMapper.insertSMajors(sMajors);
					            				
					            				majorList.add(sMajors);
				            				}
				            				
				            			} else {
				            				//后面要改
				            				errorFlag=true;
			    							errorSb.append("第"+i+"行数据"+major+"专业编码不存在。<br/>");
				            				continue;
			    							/*
				            				SMajors sMajors=new SMajors();
				            				sMajors.setMname(major);
				            				sMajors.setMcode("000000");
				            				majorsMapper.insertSMajors(sMajors);
				            				
				            				majorList.add(sMajors);
				            				*/
				            				
				            			}
			            			}
		            			}
		            			
		            			
		            		
			            		SchoolMajorYearAdmissionZk schoolMajorYearAdmission=new SchoolMajorYearAdmissionZk();
			            		schoolMajorYearAdmission.setsCode(lastSchoolCode);
			            		schoolMajorYearAdmission.setMajor(major);
			            		schoolMajorYearAdmission.setMajorCode(majorCode);
			            		schoolMajorYearAdmission.setYear(lastYear);
			            		schoolMajorYearAdmission.setMajorType(lastMajorType);
			            		schoolMajorYearAdmission.setBatch(lastBatch);
			            		if(plan!=-1) {
			            			schoolMajorYearAdmission.setPlan(plan);
			            		}
			            		
			            		if(admisson!=-1) {
			            			schoolMajorYearAdmission.setAdmission(admisson);
			            		}
			            		
			            		schoolMajorYearAdmission.setHightGrade(heightGrade);
			            		schoolMajorYearAdmission.setAvgGrade(avgGrade);
			            		schoolMajorYearAdmission.setLowGrade(lowGrade);
			            		
			            		if(admisson!=-1&&plan==-1) {
			            			errorFlag=true;
	    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的计划数为空");
	    							continue;
			            		}
			            		/*
			            		if(admisson>plan) {
			            			errorFlag=true;
	    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的投档数和计划数不对");
	    							continue;
			            		}
			            		*/
			            		schoolMajorYearAdmissionList.add(schoolMajorYearAdmission);
			            		
			            		lastMajor=major;
		            		}//专业不为空时判断结束
		            		
		            		//下面开始统计成绩
		            		if(major.equals("")) major=lastMajor;
		            		
		            		lastPlan=plan;
		                	lastAdmisson=admisson;
		                	
		                	
		                	
		            		
	            		}
	            		
	            		
	            		
	            	}//统计专业结束
            	}//excel处理结束

            	}
            }//循环处理结束
            
            
            if(errorFlag) {
            	return errorSb.toString();
            }
            
            log.info("----------begin zhinan-----"+DateUtil.now());
            
            if(schoolYearAdmissionList.size()>0) {
            	int k=0;
            	List<SchoolYearAdmissionZk> insertSchoolYearAdmissionList=new ArrayList();
            	for(int i=0;i<schoolYearAdmissionList.size();i++) {
            		SchoolYearAdmissionZk admission=schoolYearAdmissionList.get(i);
            		insertSchoolYearAdmissionList.add(admission);
            		k++;
            		if(k>500) {
            			schoolYearAdmissionZkMapper.insertSchoolYearAdmissionList(insertSchoolYearAdmissionList);
            			insertSchoolYearAdmissionList=new ArrayList();
            			k=0;
            		}
            	}
            	if(insertSchoolYearAdmissionList.size()>0) {
            		schoolYearAdmissionZkMapper.insertSchoolYearAdmissionList(insertSchoolYearAdmissionList);
            	}
            	
            }else {
            	return "获取不到文件数据，请确认文件内容是否正确！";
            }
            
            if(schoolMajorYearAdmissionList.size()>0) {
            	int k=0;
            	List<SchoolMajorYearAdmissionZk> insertSchoolMajorYearAdmissionList=new ArrayList();
            	for(int i=0;i<schoolMajorYearAdmissionList.size();i++) {
            		SchoolMajorYearAdmissionZk admission=schoolMajorYearAdmissionList.get(i);
            		insertSchoolMajorYearAdmissionList.add(admission);
            		k++;
            		if(k>500) {
            			schoolMajorYearAdmissionZkMapper.insertSchoolMajorYearAdmission2023List(insertSchoolMajorYearAdmissionList);
            			insertSchoolMajorYearAdmissionList=new ArrayList();
            			k=0;
            		}
            	}
            	if(insertSchoolMajorYearAdmissionList.size()>0) {
            		schoolMajorYearAdmissionZkMapper.insertSchoolMajorYearAdmission2023List(insertSchoolMajorYearAdmissionList);
            	}
            	
            	
            }
            
            
            if(updateSchoolYearAdmissionWsPlanList.size()>0) {
            	int k=0;
            	List<SchoolYearAdmissionZk> updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            	for(int i=0;i<updateSchoolYearAdmissionWsPlanList.size();i++) {
            		SchoolYearAdmissionZk admission=updateSchoolYearAdmissionWsPlanList.get(i);
            		updateSchoolYearAdmissionLgPlanList2.add(admission);
            		k++;
            		if(k>500) {
            			schoolYearAdmissionZkMapper.updateSchoolYearAdmissionWsTotalList(updateSchoolYearAdmissionLgPlanList2);
            			updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            			k=0;
            		}
            	}
            	if(updateSchoolYearAdmissionLgPlanList2.size()>0) {
            		schoolYearAdmissionZkMapper.updateSchoolYearAdmissionWsTotalList(updateSchoolYearAdmissionLgPlanList2);
            	}
            }
            
            if(updateSchoolYearAdmissionLgPlanList.size()>0) {
            	int k=0;
            	List<SchoolYearAdmissionZk> updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            	for(int i=0;i<updateSchoolYearAdmissionLgPlanList.size();i++) {
            		SchoolYearAdmissionZk admission=updateSchoolYearAdmissionLgPlanList.get(i);
            		updateSchoolYearAdmissionLgPlanList2.add(admission);
            		k++;
            		if(k>500) {
            			schoolYearAdmissionZkMapper.updateSchoolYearAdmissionTotalList(updateSchoolYearAdmissionLgPlanList2);
            			updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            			k=0;
            		}            		
            	}
            	if(updateSchoolYearAdmissionLgPlanList2.size()>0) {
            		schoolYearAdmissionZkMapper.updateSchoolYearAdmissionTotalList(updateSchoolYearAdmissionLgPlanList2);
            	}
            	
            }
            
            
            
            
            
            
            log.info("----------end zhinan-----"+DateUtil.now());
           
            
	    } catch (IOException e) {
	        e.printStackTrace();
	        throw new RuntimeException("导入失败");
	    } finally {
	        
	    }
		/*
		List<Map<Integer, String>> listMap = EasyExcel.read(fileName).sheet().doReadSync();
        for (Map<Integer, String> data : listMap) {
            // 返回每条数据的键值对 表示所在的列 和所在列的值
            System.out.println(  new Gson().toJson(data));
        }
        */
	    return "成功";
	}
	
	@Override
	//@Transactional
	public String imp2023(String filePath,String dataType) {
		//String fileName= "D:\\10602(1).xls"; 
		String fileName= filePath; 
		File file = new File(fileName);
		
		boolean errorFlag=false;
        StringBuffer errorSb=new StringBuffer();
		
	    try {
	    	List<Object[]> list = new ArrayList<>();
	    	
	    	InputStream inputStream = new FileInputStream(fileName);
            Workbook workbook = WorkbookFactory.create(inputStream);
            Sheet sheet = workbook.getSheetAt(0);
            //获取sheet的行数
            int rows = sheet.getLastRowNum();
            for (int i = 0; i <= rows; i++) {
            	//获取当前行的数据
                Row row = sheet.getRow(i);
                if(row!=null) {
	                Object[] objects = new Object[row.getLastCellNum()];
	                int index = 0;
	                for (int j=0;j< row.getLastCellNum();j++) {
	                	Cell cell=row.getCell(j);
	                	if(cell==null) {
	                		objects[index] = "";
	                	}else {
		                	if (cell.getCellType().equals(CellType.NUMERIC)) {
		                		int num=(int) cell.getNumericCellValue();
		                        objects[index] = new Integer(num).toString();
		                    }else {
		                    	objects[index] = cell.getStringCellValue();
		                    }
	                	}
	                	/*
	                	if (cell.getCellType().equals(CellType.STRING)) {
	                		objects[index] = cell.getStringCellValue();
	                	}
	                	*/
	                    
	                    index++;
	                }
	                list.add(objects);
                }
            }
            
            
            //取出数据库所有的专业
            List<SMajors> majorList=majorsMapper.selectSMajorsList(null);
            
            List<SchoolYearAdmission> schoolYearAdmissionList=new ArrayList();
            List<SchoolMajorYearAdmission> schoolMajorYearAdmissionList=new ArrayList();
            
            
            List<SchoolYearAdmission> updateSchoolYearAdmissionLgPlanList=new ArrayList();
            List<SchoolYearAdmission> updateSchoolYearAdmissionWsPlanList=new ArrayList();
            
            int lastYear=0;
        	String lastSchoolCode="";
        	String lastSchoolName="";
        	String lastBatch="";
        	Long schoolYearAdmissionId=null;
        	
        	int lastPlan=-1;
        	int lastSubmit=-1;
        	int lastAdmisson=-1;
        	
        	
        	int lastPlanLg=-1;
        	int lastSubmitLg=-1;
        	int lastAdmissonLg=-1;
        	
        	int lastPlanWs=-1;
        	int lastSubmitWs=-1;
        	int lastAdmissonWs=-1;
        	
        	String batch="";
        	
        	String lastMajor="";
        	String lastMajorType="";
            for(int i=0;i<list.size();i++) {
            	Object[] objArr=list.get(i);
            	if(objArr!=null&&objArr.length>0&&objArr[0]!=null) {
            	String obj1=objArr[0].toString();
            	obj1=obj1.trim();
            	int year=0;
            	String schoolCode="";
            	String schoolName="";
            	
            	
            	String major="";
            	int plan=-1;
            	int heightGrade=0;
            	int avgGrade=0;
            	int lowGrade=0;
            	
            	int admisson=-1;
            	String gradeStr="";
            	if(obj1!=null) {
	            	
            		
            		if(obj1.startsWith("本科")||obj1.startsWith("国家专项计划")||obj1.startsWith("地方")) {
	            		//本行是标题，跳过
	            		batch=obj1.toString();
	            		lastBatch=batch;
	            	}else if(obj1.startsWith("院校代码")) {
	            		//一个新的学校
		            	String yearStr="2023";
	            		
	            		year=2023;
	            		
	            		try {
		            		schoolCode=obj1.substring(obj1.indexOf("院校代码")+5, obj1.indexOf("院校名称"));
		            		schoolCode=schoolCode.trim();
		            		schoolName=obj1.substring(obj1.indexOf("院校名称")+5, obj1.length());
		            		schoolName=schoolName.trim();
		            		
	            		}catch(Exception e3) {
	            			errorFlag=true;
							errorSb.append("第"+i+"行数据："+obj1+"的院校或录取批次错误");
	            		}
	            		
	            		lastMajorType="";
	            		
	            		
	            		/*2024年6月27日，注释掉覆盖功能，因为同一批次，可能民族班又会是另外一个文件
	            		SchoolYearAdmission schoolYearAdmissionQuery=new SchoolYearAdmission();
	            		schoolYearAdmissionQuery.setsCode(schoolCode);
	            		schoolYearAdmissionQuery.setYear(year);
	            		schoolYearAdmissionQuery.setBatch(batch);
	            		List<SchoolYearAdmission> existList= schoolYearAdmissionMapper.selectSchoolYearAdmissionList(schoolYearAdmissionQuery);
	            		if(existList!=null&&existList.size()>0) {
	            			
	            			 //* 删除相关数据，重新插入
	            			
	            			schoolYearAdmissionMapper.deleteSchoolYearAdmissionByScodeYearBatch(schoolYearAdmissionQuery);
	            			
	            			SchoolMajorYearAdmission schoolMajorYearAdmission=new SchoolMajorYearAdmission();
		            		schoolMajorYearAdmission.setsCode(schoolCode);
		            		schoolMajorYearAdmission.setYear(year);
		            		schoolMajorYearAdmission.setBatch(batch);
		            		schoolMajorYearAdmissionMapper.deleteSchoolMajorYearAdmissionByScodeYearBatch(schoolMajorYearAdmission);
		            		
		            		

	            			
	            			
	            			SchoolYearAdmission schoolYearAdmission=new SchoolYearAdmission();
	            			schoolYearAdmission.setsCode(schoolCode);
		            		schoolYearAdmission.setYear(year);
		            		schoolYearAdmission.setBatch(batch);
		            		schoolYearAdmissionList.add(schoolYearAdmission);
		            		
		            		lastSchoolCode=schoolCode;
		            		lastSchoolName=schoolName;
		            		lastBatch=batch;
		            		lastYear=year;
	            		}else {
		            		SchoolYearAdmission schoolYearAdmission=new SchoolYearAdmission();
		            		schoolYearAdmission.setsCode(schoolCode);
		            		schoolYearAdmission.setYear(year);
		            		schoolYearAdmission.setBatch(batch);
		            		schoolYearAdmissionList.add(schoolYearAdmission);
		            		
		            		lastSchoolCode=schoolCode;
		            		lastSchoolName=schoolName;
		            		lastBatch=batch;
		            		lastYear=year;
	            		}
	            		*/
	            		
	            		SchoolYearAdmission schoolYearAdmission=new SchoolYearAdmission();
	            		schoolYearAdmission.setsCode(schoolCode);
	            		schoolYearAdmission.setYear(year);
	            		schoolYearAdmission.setBatch(batch);
	            		schoolYearAdmissionList.add(schoolYearAdmission);
	            		
	            		lastSchoolCode=schoolCode;
	            		lastSchoolName=schoolName;
	            		lastBatch=batch;
	            		lastYear=year;
	            		
	            	}else if(obj1.startsWith("科目组及专业名称")) {
	            		//本行是标题，跳过
	            	}else {//统计专业
	            		if(!obj1.equals("")) {
	            			major=obj1.replaceAll("\\n", "");	  
	            			major=major.trim();
	            			if(major.indexOf("，")>-1) {
	            				major=major.replaceAll("，", ",");
        					}
	            			
	            			if(major.indexOf("（")>-1) {
	            				major=major.replaceAll("（", "(");
            				}
            				if(major.indexOf("）")>-1) {
            					major=major.replaceAll("）", ")");
            				}
	            			
	            			try {
		            			if(objArr[1]!=null) {
			            			String planStr=(String)objArr[1];
			            			planStr=planStr.replaceAll("\\n", "");	  
			            			planStr=planStr.trim();
			            			if(!planStr.equals("")) {
			            				plan=new Integer(planStr);
			            			}
			            		}
			            		
			            		if(objArr[2]!=null) {
			            			String admissonStr=(String)objArr[2];
			            			admissonStr=admissonStr.replaceAll("\\n", "");	 
			            			admissonStr=admissonStr.trim();
			            			if(!admissonStr.equals("")) {
			            				admisson=new Integer(admissonStr);
			            			}
			            		}
			            		if(objArr[3]!=null) {
			            			String heightGradeStr=(String)objArr[3];
			            			heightGradeStr=heightGradeStr.replaceAll("\\n", "");	
			            			heightGradeStr=heightGradeStr.trim();
			            			if(!heightGradeStr.equals("")) {
			            				heightGrade=new Integer(heightGradeStr);
			            			}
			            		}
			            		
			            		if(objArr[4]!=null) {
			            			String avgGradeStr=(String)objArr[4];
			            			avgGradeStr=avgGradeStr.replaceAll("\\n", "");	
			            			avgGradeStr=avgGradeStr.trim();
			            			if(!avgGradeStr.equals("")) {
			            				avgGrade=new Integer(avgGradeStr);
			            			}
			            		}
			            		
			            		if(objArr[5]!=null) {
			            			String lowGradeStr=(String)objArr[5];
			            			lowGradeStr=lowGradeStr.replaceAll("\\n", "");	
			            			lowGradeStr=lowGradeStr.trim();
			            			if(!lowGradeStr.equals("")) {
			            				lowGrade=new Integer(lowGradeStr);
			            			}
			            		}
			            		
			            		
			            		
	            			}catch(Exception e3) {
	            				errorFlag=true;
    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据");
    							if(objArr.length>1) {
    								errorSb.append(objArr[1]);
    							}
    							if(objArr.length>2) {
    								errorSb.append(objArr[2]);
    							}
    							if(objArr.length>3) {
    								errorSb.append(objArr[3]);
    							}
    							if(objArr.length>4) {
    								errorSb.append(objArr[4]);
    							}
    							
    							if(objArr.length>5) {
    								errorSb.append(objArr[5]);
    							}
    							errorSb.append("错误。<br/>");
    							continue;
	            			}
		            		
		            		if(!major.equals("")) {
		            			
		            			boolean majorFlag=false;//专业名相同标志
		            			boolean majorKHFlag=false;//专业括号名相同标志
		            			int sameMajor=0;
		            			String majorCode="";
		            			
		            			if("理工类".equals(major)) {
		            				lastMajorType="理工类";
		            				
		            				SchoolYearAdmission schoolYearAdmission=new SchoolYearAdmission();
				            		schoolYearAdmission.setsCode(lastSchoolCode);
				            		schoolYearAdmission.setYear(lastYear);
				            		schoolYearAdmission.setBatch(lastBatch);
				            		if(admisson==-1) {
				            			schoolYearAdmission.setAdmissionLg(0);
				            		}else {
				            			schoolYearAdmission.setAdmissionLg(admisson);
				            		}
				            		
				            		if(plan==-1) {
				            			schoolYearAdmission.setPlanLg(0);
				            		}else {
				            			schoolYearAdmission.setPlanLg(plan);
				            		}

				            		
				            		
				            		updateSchoolYearAdmissionLgPlanList.add(schoolYearAdmission);

		            			}else if("文史类".equals(major)) {
		            				lastMajorType="文史类";
		            				
		            				SchoolYearAdmission schoolYearAdmission=new SchoolYearAdmission();
				            		schoolYearAdmission.setsCode(lastSchoolCode);
				            		schoolYearAdmission.setYear(lastYear);
				            		schoolYearAdmission.setBatch(lastBatch);
				            		if(admisson==-1) {
				            			schoolYearAdmission.setAdmissionWs(0);
				            		}else {
				            			schoolYearAdmission.setAdmissionWs(admisson);
				            		}
				            		if(plan==-1) {
				            			
				            		}else {
				            			schoolYearAdmission.setPlanWs(plan);
				            		}
				            		
				            		
				            		updateSchoolYearAdmissionWsPlanList.add(schoolYearAdmission);
		            			}else {
		            			
			            			for(int k=0;k<majorList.size();k++) {
			            				SMajors majorObj=majorList.get(k);
			            				if(majorObj.getMname().equals(major)) {//如果专业存在，不做处理
			            					majorCode=majorObj.getMcode();
			            					majorFlag=true;
			            					break;
			            				}
			            			}
			            			if(!majorFlag) {//如果专业不存在，需要插入专业表
			            				if(major.indexOf("（")>-1&&major.indexOf("）")>-1) {//判断是否包含中文括号
				            				String major1=major.substring(0, major.indexOf("（"));
				            				String major2=major.substring( major.indexOf("（")+1,major.length());
				            				
				            				for(int m=0;m<majorList.size();m++) {
					            				SMajors majorObj2=majorList.get(m);
					            				String name2=majorObj2.getMname();
					            				if(name2.indexOf("(")>-1) {
					            					name2=name2.replaceAll("\\(", "（");
					            				}
					            				if(name2.indexOf(")")>-1) {
					            					name2=name2.replaceAll("\\)", "）");
					            				}
					            				if(name2.indexOf("，")>-1) {
					            					name2=name2.replaceAll("，", ",");
					            				}
					            				if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
					            					majorCode=majorObj2.getMcode();
					            					majorKHFlag=true;
					            					break;
					            				}
				            				}
				            				
				            				if(majorKHFlag) {
				            					
				            					for(int m=0;m<majorList.size();m++) {
						            				SMajors majorObj2=majorList.get(m);
						            				if(majorObj2.getMname().indexOf("（")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else if(majorObj2.getMname().indexOf("(")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else {
						            					if(majorObj2.getMname().equals(major1)) {
							            					sameMajor++;
							            				}
						            				}
						            				
				            					}
				            					String code="";
				            					sameMajor++;
				            					if(sameMajor>9) {
				            						code=new Integer(sameMajor).toString();
				            					}else {
				            						code="0"+sameMajor;
				            					}
				            					SMajors sMajors=new SMajors();
				            					sMajors.setMname(major);
				            					if(majorCode!=null) {
				            						if(sMajors.getMname().indexOf("类")>-1) {
				            							sMajors.setMcode(majorCode+"0"+code);
				            							majorCode=majorCode+"0"+code;
				            						}else {
				            							sMajors.setMcode(majorCode+code);
				            							majorCode=majorCode+code;
				            						}
				            					}else {
				            						sMajors.setMcode(code);
				            						majorCode=code;
				            					}
				            					sMajors.setCreateTime(new Date());
					            				majorsMapper.insertSMajors(sMajors);
					            				
					            				majorList.add(sMajors);
				            				}
				            				
				            			}else if(major.indexOf("(")>-1&&major.indexOf(")")>-1) {//判断是否包含中文括号
				            				String major1=major.substring(0, major.indexOf("("));
				            				String major2=major.substring( major.indexOf("(")+1,major.length());
				            				
				            				for(int m=0;m<majorList.size();m++) {
					            				SMajors majorObj2=majorList.get(m);
					            				String name2=majorObj2.getMname();
					            				if(name2.indexOf("（")>-1) {
					            					name2=name2.replaceAll("（", "(");
					            				}
					            				if(name2.indexOf("）")>-1) {
					            					name2=name2.replaceAll("）", ")");
					            				}
					            				if(name2.indexOf("，")>-1) {
					            					name2=name2.replaceAll("，", ",");
					            				}
					            				if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
					            					majorCode=majorObj2.getMcode();
					            					majorKHFlag=true;
					            					break;
					            				}
				            				}
				            				
				            				if(majorKHFlag) {
				            					
				            					for(int m=0;m<majorList.size();m++) {
						            				SMajors majorObj2=majorList.get(m);
						            				if(majorObj2.getMname().indexOf("（")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else if(majorObj2.getMname().indexOf("(")>-1) {
						            					String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
							            				if(major3.equals(major1)) {
							            					sameMajor++;
							            				}
						            				}else {
						            					if(majorObj2.getMname().equals(major1)) {
							            					sameMajor++;
							            				}
						            				}
						            				
				            					}
				            					String code="";
				            					sameMajor++;
				            					if(sameMajor>9) {
				            						code=new Integer(sameMajor).toString();
				            					}else {
				            						code="0"+sameMajor;
				            					}
				            					SMajors sMajors=new SMajors();
				            					sMajors.setMname(major);
				            					if(majorCode!=null) {
				            						if(sMajors.getMname().indexOf("类")>-1) {
				            							sMajors.setMcode(majorCode+"0"+code);
				            							majorCode=majorCode+"0"+code;
				            						}else {
				            							sMajors.setMcode(majorCode+code);
				            							majorCode=majorCode+code;
				            						}
				            					}else {
				            						sMajors.setMcode(code);
				            						majorCode=code;
				            					}
				            					sMajors.setCreateTime(new Date());
					            				majorsMapper.insertSMajors(sMajors);
					            				
					            				majorList.add(sMajors);
				            				}
				            				
				            			} else {
				            				//后面要改
				            				errorFlag=true;
			    							errorSb.append("第"+i+"行数据"+major+"专业编码不存在。<br/>");
				            				continue;
			    							/*
				            				SMajors sMajors=new SMajors();
				            				sMajors.setMname(major);
				            				sMajors.setMcode("000000");
				            				majorsMapper.insertSMajors(sMajors);
				            				
				            				majorList.add(sMajors);
				            				*/
				            				
				            			}
			            			}
		            			}
		            			
		            			
		            		
			            		SchoolMajorYearAdmission schoolMajorYearAdmission=new SchoolMajorYearAdmission();
			            		schoolMajorYearAdmission.setsCode(lastSchoolCode);
			            		schoolMajorYearAdmission.setMajor(major);
			            		if(!majorCode.equals("")) {
				            		if(lastBatch.equals("国家专项计划")) {
				            			majorCode=majorCode+"0";
				            		}
				            		if(lastBatch.equals("地方专项计划")) {
				            			majorCode=majorCode+"00";
				            		}
			            		}
			            		schoolMajorYearAdmission.setMajorCode(majorCode);
			            		schoolMajorYearAdmission.setYear(lastYear);
			            		schoolMajorYearAdmission.setMajorType(lastMajorType);
			            		schoolMajorYearAdmission.setBatch(lastBatch);
			            		if(plan!=-1) {
			            			schoolMajorYearAdmission.setPlan(plan);
			            		}
			            		
			            		if(admisson!=-1) {
			            			schoolMajorYearAdmission.setAdmission(admisson);
			            		}
			            		
			            		schoolMajorYearAdmission.setHightGrade(heightGrade);
			            		schoolMajorYearAdmission.setAvgGrade(avgGrade);
			            		schoolMajorYearAdmission.setLowGrade(lowGrade);
			            		
			            		if(admisson!=-1&&plan==-1) {
			            			errorFlag=true;
	    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的计划数为空");
	    							continue;
			            		}
			            		/*
			            		if(admisson>plan) {
			            			errorFlag=true;
	    							errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的投档数和计划数不对");
	    							continue;
			            		}
			            		*/
			            		schoolMajorYearAdmissionList.add(schoolMajorYearAdmission);
			            		
			            		lastMajor=major;
		            		}//专业不为空时判断结束
		            		
		            		//下面开始统计成绩
		            		if(major.equals("")) major=lastMajor;
		            		
		            		lastPlan=plan;
		                	lastAdmisson=admisson;
		                	
		                	
		                	
		            		
	            		}
	            		
	            		
	            		
	            	}//统计专业结束
            	}//excel处理结束

            	}
            }//循环处理结束
            
            
            if(errorFlag) {
            	return errorSb.toString();
            }
            
            log.info("----------begin zhinan-----"+DateUtil.now());
            
            if(schoolYearAdmissionList.size()>0) {
            	int k=0;
            	List<SchoolYearAdmission> insertSchoolYearAdmissionList=new ArrayList();
            	for(int i=0;i<schoolYearAdmissionList.size();i++) {
            		SchoolYearAdmission admission=schoolYearAdmissionList.get(i);
            		admission.setBatch(lastBatch);
            		insertSchoolYearAdmissionList.add(admission);
            		k++;
            		if(k>500) {
            			schoolYearAdmissionMapper.insertSchoolYearAdmissionList(insertSchoolYearAdmissionList);
            			insertSchoolYearAdmissionList=new ArrayList();
            			k=0;
            		}
            	}
            	if(insertSchoolYearAdmissionList.size()>0) {
            		schoolYearAdmissionMapper.insertSchoolYearAdmissionList(insertSchoolYearAdmissionList);
            	}
            	
            }else {
            	return "获取不到文件数据，请确认文件内容是否正确！";
            }
            
            if(schoolMajorYearAdmissionList.size()>0) {
            	int k=0;
            	List<SchoolMajorYearAdmission> insertSchoolMajorYearAdmissionList=new ArrayList();
            	for(int i=0;i<schoolMajorYearAdmissionList.size();i++) {
            		SchoolMajorYearAdmission admission=schoolMajorYearAdmissionList.get(i);
            		admission.setBatch(lastBatch);
            		insertSchoolMajorYearAdmissionList.add(admission);
            		k++;
            		if(k>500) {
            			schoolMajorYearAdmissionMapper.insertSchoolMajorYearAdmission2023List(insertSchoolMajorYearAdmissionList);
            			insertSchoolMajorYearAdmissionList=new ArrayList();
            			k=0;
            		}
            	}
            	if(insertSchoolMajorYearAdmissionList.size()>0) {
            		schoolMajorYearAdmissionMapper.insertSchoolMajorYearAdmission2023List(insertSchoolMajorYearAdmissionList);
            	}
            	
            	
            }
            
            
            if(updateSchoolYearAdmissionWsPlanList.size()>0) {
            	int k=0;
            	List<SchoolYearAdmission> updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            	for(int i=0;i<updateSchoolYearAdmissionWsPlanList.size();i++) {
            		SchoolYearAdmission admission=updateSchoolYearAdmissionWsPlanList.get(i);
            		updateSchoolYearAdmissionLgPlanList2.add(admission);
            		k++;
            		if(k>500) {
            			schoolYearAdmissionMapper.updateSchoolYearAdmissionWsTotalList(updateSchoolYearAdmissionLgPlanList2);
            			updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            			k=0;
            		}
            	}
            	if(updateSchoolYearAdmissionLgPlanList2.size()>0) {
            		schoolYearAdmissionMapper.updateSchoolYearAdmissionWsTotalList(updateSchoolYearAdmissionLgPlanList2);
            	}
            }
            
            if(updateSchoolYearAdmissionLgPlanList.size()>0) {
            	int k=0;
            	List<SchoolYearAdmission> updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            	for(int i=0;i<updateSchoolYearAdmissionLgPlanList.size();i++) {
            		SchoolYearAdmission admission=updateSchoolYearAdmissionLgPlanList.get(i);
            		updateSchoolYearAdmissionLgPlanList2.add(admission);
            		k++;
            		if(k>500) {
            			schoolYearAdmissionMapper.updateSchoolYearAdmissionTotalList(updateSchoolYearAdmissionLgPlanList2);
            			updateSchoolYearAdmissionLgPlanList2=new ArrayList();
            			k=0;
            		}            		
            	}
            	if(updateSchoolYearAdmissionLgPlanList2.size()>0) {
            		schoolYearAdmissionMapper.updateSchoolYearAdmissionTotalList(updateSchoolYearAdmissionLgPlanList2);
            	}
            	
            }
            
            
            
            
            
            
            log.info("----------end zhinan-----"+DateUtil.now());
           
            
	    } catch (IOException e) {
	        e.printStackTrace();
	        throw new RuntimeException("导入失败");
	    } finally {
	        
	    }
		/*
		List<Map<Integer, String>> listMap = EasyExcel.read(fileName).sheet().doReadSync();
        for (Map<Integer, String> data : listMap) {
            // 返回每条数据的键值对 表示所在的列 和所在列的值
            System.out.println(  new Gson().toJson(data));
        }
        */
	    return "成功";
	}

	@Override
	@Transactional
	public String imp2024(String filePath,String dataType) {
		//String fileName= "D:\\095.xls";
		String fileName= filePath;
		File file = new File(fileName);

		boolean errorFlag=false;
		StringBuffer errorSb=new StringBuffer();

		try {
			List<Object[]> list = new ArrayList<>();

			InputStream inputStream = new FileInputStream(fileName);
			Workbook workbook = WorkbookFactory.create(inputStream);
			Sheet sheet = workbook.getSheetAt(0);
			//获取sheet的行数
			int rows = sheet.getLastRowNum();
			for (int i = 0; i <= rows; i++) {
				//获取当前行的数据
				Row row = sheet.getRow(i);
				if(row!=null) {
					Object[] objects = new Object[row.getLastCellNum()];

					int index = 0;
					for (int j=0;j< row.getLastCellNum();j++) {
						Cell cell=row.getCell(j);
						if(cell==null) {
							objects[index] = "";
						}else {
							if (cell.getCellType().equals(CellType.NUMERIC)) {
								int num=(int) cell.getNumericCellValue();
								objects[index] = new Integer(num).toString();
							}else {
								objects[index] = cell.getStringCellValue();
							}
						}
	                	/*
	                	if (cell.getCellType().equals(CellType.STRING)) {
	                		objects[index] = cell.getStringCellValue();
	                	}
	                	*/

						index++;
					}

					list.add(objects);
				}


			}


			//取出数据库所有的专业
			List<SMajors> majorList=majorsMapper.selectSMajorsList(null);

			List<SchoolYearAdmission> schoolYearAdmissionList=new ArrayList();
			List<SchoolMajorYearAdmission> schoolMajorYearAdmissionList=new ArrayList();
			List<SchoolZyzYearAdmission> schoolZyzYearAdmissionList=new ArrayList();


			List<SchoolYearAdmission> updateSchoolYearAdmissionLgPlanList=new ArrayList();
			List<SchoolYearAdmission> updateSchoolYearAdmissionWsPlanList=new ArrayList();

			int lastYear=2024;
			String lastSchoolCode="";
			String lastSchoolName="";
			String lastBatch="";
			Long schoolYearAdmissionId=null;

			int lastPlan=-1;
			int lastSubmit=-1;
			int lastAdmisson=-1;


			int lastPlanLg=-1;
			int lastSubmitLg=-1;
			int lastAdmissonLg=-1;

			int lastPlanWs=-1;
			int lastSubmitWs=-1;
			int lastAdmissonWs=-1;

			String batch="";

			String lastMajor="";
			String lastMajorType="";
			String lastZyz="";
			for(int i=0;i<list.size();i++) {
				Object[] objArr=list.get(i);
				if(objArr!=null&&objArr.length>0&&objArr[0]!=null) {
					String obj1=objArr[0].toString();
					obj1=obj1.trim();
					int year=0;
					String schoolCode="";
					String schoolName="";


					String major="";
					int plan=-1;
					int heightGrade=0;
					int avgGrade=0;
					int lowGrade=0;
					int lowGradeSeq=0;

					int admisson=-1;
					String gradeStr="";
					if(obj1!=null) {


						if(obj1.startsWith("本科普通")||obj1.startsWith("国家专项")||obj1.startsWith("地方")) {
							//本行是标题，跳过
							batch=obj1.toString();
							lastBatch=batch;
						}else if(obj1.startsWith("院校代码")) {
							//一个新的学校
							String yearStr="2024";

							year=2024;

							try {
								schoolCode=obj1.substring(obj1.indexOf("院校代码")+5, obj1.indexOf("院校名称"));
								schoolCode=schoolCode.trim();
								schoolName=obj1.substring(obj1.indexOf("院校名称")+5, obj1.length());
								schoolName=schoolName.trim();

							}catch(Exception e3) {
								errorFlag=true;
								errorSb.append("第"+i+"行数据："+obj1+"的院校或录取批次错误");
							}

							lastMajorType="";




							SchoolYearAdmission schoolYearAdmission=new SchoolYearAdmission();
							schoolYearAdmission.setsCode(schoolCode);
							schoolYearAdmission.setYear(year);
							schoolYearAdmission.setBatch(batch);
							schoolYearAdmissionList.add(schoolYearAdmission);

							lastSchoolCode=schoolCode;
							lastSchoolName=schoolName;
							lastBatch=batch;
							lastYear=year;

						}else if(obj1.startsWith("科目组及专业名称")) {
							//本行是标题，跳过
						}else if(obj1.startsWith("历史类")||obj1.startsWith("物理类")) {
							if(obj1.startsWith("历史类")){
								lastMajorType="文史类";
							}
							if(obj1.startsWith("物理类")){
								lastMajorType="理工类";
							}
						}else if(obj1.startsWith("专业组")) {
							if(obj1.indexOf(":")>0){
								String[] zyzArr=obj1.split(":");
								String zyz=zyzArr[1].trim();
								lastZyz=zyz;
							}
							if(obj1.indexOf("：")>0){
								String[] zyzArr=obj1.split("：");
								String zyz=zyzArr[1].trim();
								lastZyz=zyz;
							}

							try {
								if(objArr[1]!=null) {
									String planStr=(String)objArr[1];
									planStr=planStr.replaceAll("\\n", "");
									planStr=planStr.trim();
									if(!planStr.equals("")) {
										plan=new Integer(planStr);
									}
								}

								if(objArr[2]!=null) {
									String admissonStr=(String)objArr[2];
									admissonStr=admissonStr.replaceAll("\\n", "");
									admissonStr=admissonStr.trim();
									if(!admissonStr.equals("")) {
										admisson=new Integer(admissonStr);
									}
								}
								if(objArr[3]!=null) {
									String heightGradeStr=(String)objArr[3];
									heightGradeStr=heightGradeStr.replaceAll("\\n", "");
									heightGradeStr=heightGradeStr.trim();
									if(!heightGradeStr.equals("")) {
										heightGrade=new Integer(heightGradeStr);
									}
								}

								if(objArr[4]!=null) {
									String avgGradeStr=(String)objArr[4];
									avgGradeStr=avgGradeStr.replaceAll("\\n", "");
									avgGradeStr=avgGradeStr.trim();
									if(!avgGradeStr.equals("")) {
										avgGrade=new Integer(avgGradeStr);
									}
								}

								if(objArr[5]!=null) {
									String lowGradeStr=(String)objArr[5];
									lowGradeStr=lowGradeStr.replaceAll("\\n", "");
									lowGradeStr=lowGradeStr.trim();
									if(!lowGradeStr.equals("")) {
										lowGrade=new Integer(lowGradeStr);
									}
								}
								if(objArr[6]!=null) {
									String lowGradeSeqStr=(String)objArr[6];
									lowGradeSeqStr=lowGradeSeqStr.replaceAll("\\n", "");
									lowGradeSeqStr=lowGradeSeqStr.trim();
									if(!lowGradeSeqStr.equals("")) {
										lowGradeSeq=new Integer(lowGradeSeqStr);
									}
								}


							}catch(Exception e3) {
								errorFlag=true;
								errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业组："+lastZyz+"的数据");
								if(objArr.length>1) {
									errorSb.append(objArr[1]);
								}
								if(objArr.length>2) {
									errorSb.append(objArr[2]);
								}
								if(objArr.length>3) {
									errorSb.append(objArr[3]);
								}
								if(objArr.length>4) {
									errorSb.append(objArr[4]);
								}

								if(objArr.length>5) {
									errorSb.append(objArr[5]);
								}
								errorSb.append("错误。<br/>");
								continue;
							}


							SchoolZyzYearAdmission zyzYearAdmission=new SchoolZyzYearAdmission();
							zyzYearAdmission.setsCode(lastSchoolCode);
							zyzYearAdmission.setZyz(lastZyz);
							zyzYearAdmission.setMajorType(lastMajorType);
							zyzYearAdmission.setPlan(plan);
							zyzYearAdmission.setBatch(lastBatch);
							zyzYearAdmission.setAvgGrade(avgGrade);
							zyzYearAdmission.setHightGrade(heightGrade);
							zyzYearAdmission.setLowGrade(lowGrade);
							zyzYearAdmission.setLowGradeSeq(lowGradeSeq);
							zyzYearAdmission.setYear(lastYear);
							zyzYearAdmission.setAdmission(admisson);
							schoolZyzYearAdmissionList.add(zyzYearAdmission);

						}else {//统计专业
							if(!obj1.equals("")) {
								major=obj1.replaceAll("\\n", "");
								major=major.trim();
								if(major.indexOf("，")>-1) {
									major=major.replaceAll("，", ",");
								}

								if(major.indexOf("（")>-1) {
									major=major.replaceAll("（", "(");
								}
								if(major.indexOf("）")>-1) {
									major=major.replaceAll("）", ")");
								}

								try {
									if(objArr[1]!=null) {
										String planStr=(String)objArr[1];
										planStr=planStr.replaceAll("\\n", "");
										planStr=planStr.trim();
										if(!planStr.equals("")) {
											plan=new Integer(planStr);
										}
									}

									if(objArr[2]!=null) {
										String admissonStr=(String)objArr[2];
										admissonStr=admissonStr.replaceAll("\\n", "");
										admissonStr=admissonStr.trim();
										if(!admissonStr.equals("")) {
											admisson=new Integer(admissonStr);
										}
									}
									if(objArr[3]!=null) {
										String heightGradeStr=(String)objArr[3];
										heightGradeStr=heightGradeStr.replaceAll("\\n", "");
										heightGradeStr=heightGradeStr.trim();
										if(!heightGradeStr.equals("")) {
											heightGrade=new Integer(heightGradeStr);
										}
									}

									if(objArr[4]!=null) {
										String avgGradeStr=(String)objArr[4];
										avgGradeStr=avgGradeStr.replaceAll("\\n", "");
										avgGradeStr=avgGradeStr.trim();
										if(!avgGradeStr.equals("")) {
											avgGrade=new Integer(avgGradeStr);
										}
									}

									if(objArr[5]!=null) {
										String lowGradeStr=(String)objArr[5];
										lowGradeStr=lowGradeStr.replaceAll("\\n", "");
										lowGradeStr=lowGradeStr.trim();
										if(!lowGradeStr.equals("")) {
											lowGrade=new Integer(lowGradeStr);
										}
									}
									if(objArr[6]!=null) {
										String lowGradeSeqStr=(String)objArr[6];
										lowGradeSeqStr=lowGradeSeqStr.replaceAll("\\n", "");
										lowGradeSeqStr=lowGradeSeqStr.trim();
										if(!lowGradeSeqStr.equals("")) {
											lowGradeSeq=new Integer(lowGradeSeqStr);
										}
									}


								}catch(Exception e3) {
									errorFlag=true;
									errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的数据");
									if(objArr.length>1) {
										errorSb.append(objArr[1]);
									}
									if(objArr.length>2) {
										errorSb.append(objArr[2]);
									}
									if(objArr.length>3) {
										errorSb.append(objArr[3]);
									}
									if(objArr.length>4) {
										errorSb.append(objArr[4]);
									}

									if(objArr.length>5) {
										errorSb.append(objArr[5]);
									}
									errorSb.append("错误。<br/>");
									continue;
								}

								if(!major.equals("")) {

									boolean majorFlag=false;//专业名相同标志
									boolean majorKHFlag=false;//专业括号名相同标志
									int sameMajor=0;
									String majorCode="";



									for(int k=0;k<majorList.size();k++) {
										SMajors majorObj=majorList.get(k);
										if(majorObj.getMname().equals(major)) {//如果专业存在，不做处理
											majorCode=majorObj.getMcode();
											majorFlag=true;
											break;
										}
									}
									if(!majorFlag) {//如果专业不存在，需要插入专业表
										if(major.indexOf("（")>-1&&major.indexOf("）")>-1) {//判断是否包含中文括号
											String major1=major.substring(0, major.indexOf("（"));
											String major2=major.substring( major.indexOf("（")+1,major.length());

											for(int m=0;m<majorList.size();m++) {
												SMajors majorObj2=majorList.get(m);
												String name2=majorObj2.getMname();
												if(name2.indexOf("(")>-1) {
													name2=name2.replaceAll("\\(", "（");
												}
												if(name2.indexOf(")")>-1) {
													name2=name2.replaceAll("\\)", "）");
												}
												if(name2.indexOf("，")>-1) {
													name2=name2.replaceAll("，", ",");
												}
												if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
													majorCode=majorObj2.getMcode();
													majorKHFlag=true;
													break;
												}
											}

											if(majorKHFlag) {

												for(int m=0;m<majorList.size();m++) {
													SMajors majorObj2=majorList.get(m);
													if(majorObj2.getMname().indexOf("（")>-1) {
														String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
														if(major3.equals(major1)) {
															sameMajor++;
														}
													}else if(majorObj2.getMname().indexOf("(")>-1) {
														String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
														if(major3.equals(major1)) {
															sameMajor++;
														}
													}else {
														if(majorObj2.getMname().equals(major1)) {
															sameMajor++;
														}
													}

												}
												String code="";
												sameMajor++;
												if(sameMajor>9) {
													code=new Integer(sameMajor).toString();
												}else {
													code="0"+sameMajor;
												}
												SMajors sMajors=new SMajors();
												sMajors.setMname(major);
												if(majorCode!=null) {
													if(sMajors.getMname().indexOf("类")>-1) {
														sMajors.setMcode(majorCode+"0"+code);
														majorCode=majorCode+"0"+code;
													}else {
														sMajors.setMcode(majorCode+code);
														majorCode=majorCode+code;
													}
												}else {
													sMajors.setMcode(code);
													majorCode=code;
												}
												sMajors.setCreateTime(new Date());
												majorsMapper.insertSMajors(sMajors);

												majorList.add(sMajors);
											}

										}else if(major.indexOf("(")>-1&&major.indexOf(")")>-1) {//判断是否包含中文括号
											String major1=major.substring(0, major.indexOf("("));
											String major2=major.substring( major.indexOf("(")+1,major.length());

											for(int m=0;m<majorList.size();m++) {
												SMajors majorObj2=majorList.get(m);
												String name2=majorObj2.getMname();
												if(name2.indexOf("（")>-1) {
													name2=name2.replaceAll("（", "(");
												}
												if(name2.indexOf("）")>-1) {
													name2=name2.replaceAll("）", ")");
												}
												if(name2.indexOf("，")>-1) {
													name2=name2.replaceAll("，", ",");
												}
												if(majorObj2.getMname().equals(major1)||name2.equals(major1)) {//如果专业存在，则把 带括号的专业新增，专业编号按顺序添加
													majorCode=majorObj2.getMcode();
													majorKHFlag=true;
													break;
												}
											}

											if(majorKHFlag) {

												for(int m=0;m<majorList.size();m++) {
													SMajors majorObj2=majorList.get(m);
													if(majorObj2.getMname().indexOf("（")>-1) {
														String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("（"));
														if(major3.equals(major1)) {
															sameMajor++;
														}
													}else if(majorObj2.getMname().indexOf("(")>-1) {
														String major3=majorObj2.getMname().substring(0, majorObj2.getMname().indexOf("("));
														if(major3.equals(major1)) {
															sameMajor++;
														}
													}else {
														if(majorObj2.getMname().equals(major1)) {
															sameMajor++;
														}
													}

												}
												String code="";
												sameMajor++;
												if(sameMajor>9) {
													code=new Integer(sameMajor).toString();
												}else {
													code="0"+sameMajor;
												}
												SMajors sMajors=new SMajors();
												sMajors.setMname(major);
												if(majorCode!=null) {
													if(sMajors.getMname().indexOf("类")>-1) {
														sMajors.setMcode(majorCode+"0"+code);
														majorCode=majorCode+"0"+code;
													}else {
														sMajors.setMcode(majorCode+code);
														majorCode=majorCode+code;
													}
												}else {
													sMajors.setMcode(code);
													majorCode=code;
												}
												sMajors.setCreateTime(new Date());
												majorsMapper.insertSMajors(sMajors);

												majorList.add(sMajors);
											}

										} else {
											//后面要改
											errorFlag=true;
											errorSb.append("第"+i+"行数据"+major+"专业编码不存在。<br/>");
											continue;

										}
									}




									SchoolMajorYearAdmission schoolMajorYearAdmission=new SchoolMajorYearAdmission();
									schoolMajorYearAdmission.setsCode(lastSchoolCode);
									schoolMajorYearAdmission.setMajor(major);
									if(!majorCode.equals("")) {
										if(lastBatch.equals("国家专项计划")) {
											majorCode=majorCode+"0";
										}
										if(lastBatch.equals("地方专项计划")) {
											majorCode=majorCode+"00";
										}
									}
									schoolMajorYearAdmission.setMajorCode(majorCode);
									schoolMajorYearAdmission.setYear(lastYear);
									schoolMajorYearAdmission.setMajorType(lastMajorType);
									schoolMajorYearAdmission.setBatch(lastBatch);
									schoolMajorYearAdmission.setZyz(lastZyz);
									if(plan!=-1) {
										schoolMajorYearAdmission.setPlan(plan);
									}

									if(admisson!=-1) {
										schoolMajorYearAdmission.setAdmission(admisson);
									}

									schoolMajorYearAdmission.setHightGrade(heightGrade);
									schoolMajorYearAdmission.setAvgGrade(avgGrade);
									schoolMajorYearAdmission.setLowGrade(lowGrade);
									schoolMajorYearAdmission.setLowGradeSeq(lowGradeSeq);

									if(admisson!=-1&&plan==-1) {
										errorFlag=true;
										errorSb.append("第"+i+"行数据学校代码："+lastSchoolCode+"专业："+major+"的计划数为空");
										continue;
									}

									schoolMajorYearAdmissionList.add(schoolMajorYearAdmission);

									lastMajor=major;
								}//专业不为空时判断结束

								//下面开始统计成绩
								if(major.equals("")) major=lastMajor;

								lastPlan=plan;
								lastAdmisson=admisson;

							}

						}//统计专业结束
					}//excel处理结束

				}
			}//循环处理结束


			if(errorFlag) {
				return errorSb.toString();
			}

			log.info("----------begin zhinan-----"+DateUtil.now());

			if(schoolYearAdmissionList.size()>0) {
				int k=0;
				List<SchoolYearAdmission> insertSchoolYearAdmissionList=new ArrayList();
				for(int i=0;i<schoolYearAdmissionList.size();i++) {
					SchoolYearAdmission admission=schoolYearAdmissionList.get(i);
					admission.setBatch(lastBatch);
					insertSchoolYearAdmissionList.add(admission);
					k++;
					if(k>500) {
						schoolYearAdmissionMapper.insertSchoolYearAdmissionList(insertSchoolYearAdmissionList);
						insertSchoolYearAdmissionList=new ArrayList();
						k=0;
					}
				}
				if(insertSchoolYearAdmissionList.size()>0) {
					schoolYearAdmissionMapper.insertSchoolYearAdmissionList(insertSchoolYearAdmissionList);
				}

			}else {
				return "获取不到文件数据，请确认文件内容是否正确！";
			}

			if(schoolZyzYearAdmissionList.size()>0) {
				schoolZyzYearAdmissionMapper.insertSchoolZyzYearAdmission2024List(schoolZyzYearAdmissionList);
			}

			if(schoolMajorYearAdmissionList.size()>0) {
				int k=0;
				List<SchoolMajorYearAdmission> insertSchoolMajorYearAdmissionList=new ArrayList();
				for(int i=0;i<schoolMajorYearAdmissionList.size();i++) {
					SchoolMajorYearAdmission admission=schoolMajorYearAdmissionList.get(i);
					admission.setBatch(lastBatch);
					insertSchoolMajorYearAdmissionList.add(admission);
					k++;
					if(k>500) {
						schoolMajorYearAdmissionMapper.insertSchoolMajorYearAdmission2024List(insertSchoolMajorYearAdmissionList);
						insertSchoolMajorYearAdmissionList=new ArrayList();
						k=0;
					}
				}
				if(insertSchoolMajorYearAdmissionList.size()>0) {
					schoolMajorYearAdmissionMapper.insertSchoolMajorYearAdmission2024List(insertSchoolMajorYearAdmissionList);
				}


			}



			addSchoolPlanAdmissionLow("理工类",2024);

			addSchoolPlanAdmissionLow("文史类",2024);


			addSchoolPlanZyzPlan(2024,"理工类");
			addSchoolPlanZyzPlan(2024,"文史类");


			log.info("----------end zhinan-----"+DateUtil.now());


		} catch (IOException e) {
			e.printStackTrace();
			throw new RuntimeException("导入失败");
		} finally {

		}
		/*
		List<Map<Integer, String>> listMap = EasyExcel.read(fileName).sheet().doReadSync();
        for (Map<Integer, String> data : listMap) {
            // 返回每条数据的键值对 表示所在的列 和所在列的值
            System.out.println(  new Gson().toJson(data));
        }
        */
		return "成功";
	}


	public void addSchoolPlanAdmissionLow(String majorType, Integer year)
	{


		SchoolMajorYearAdmission majorYearAdmissionQuery=new SchoolMajorYearAdmission();
		majorYearAdmissionQuery.setYear(year);
		majorYearAdmissionQuery.setMajorType(majorType);
		//majorYearAdmissionQuery.setsCode(schoolCode);
		//majorYearAdmissionQuery.setZyz(zyz);
		List<SchoolMajorYearAdmission> admissonList2023= schoolMajorYearAdmissionService.selectSchoolMajorYearAdmission2022List(majorYearAdmissionQuery);



		SchoolPlan schoolPlanQuery=new SchoolPlan();
		schoolPlanQuery.setYear(2025);
		schoolPlanQuery.setMajorType(majorType);
		List<SchoolPlan> list2024=schoolPlanService.selectSchoolPlanList2(schoolPlanQuery);






		//广西排位分
		GkGradeDoc gkGradeDoc=new GkGradeDoc();
		gkGradeDoc.setYear(year);
		if("理工类".equals(majorType)) {
			gkGradeDoc.setGradeClass("工类");
		}
		if("文史类".equals(majorType)) {
			gkGradeDoc.setGradeClass("史类");
		}
		gkGradeDoc.setUseIn("广西");
		List<GkGradeDoc> gradeList=gkGradeDocService.selectGkGradeDocList(gkGradeDoc);


		//全国认可加分排位分
		gkGradeDoc=new GkGradeDoc();
		gkGradeDoc.setYear(year);
		if("理工类".equals(majorType)) {
			gkGradeDoc.setGradeClass("工类");
		}
		if("文史类".equals(majorType)) {
			gkGradeDoc.setGradeClass("史类");
		}
		gkGradeDoc.setUseIn("全国");
		List<GkGradeDoc> gradeList2=gkGradeDocService.selectGkGradeDocList(gkGradeDoc);



		List<SchoolPlan> addList=new ArrayList();


		for(int i=0;i<admissonList2023.size();i++){


			SchoolMajorYearAdmission admin2023=admissonList2023.get(i);
			String schoolCode=admin2023.getsCode();
			String major=admin2023.getMajor();
			String majorCode=admin2023.getMajorCode();
			String zyz=admin2023.getZyz();

			for(int k=0;k<list2024.size();k++) {

				SchoolPlan p2023=list2024.get(k);
				String schoolCode2=p2023.getSchoolCode();
				String majorName2=p2023.getMajorName();
				String majorCode2=p2023.getMajorCode();
				String zyz2=p2023.getZyz();

				boolean flag=false;
				if(schoolCode.equals(schoolCode2)&&major.equals(majorName2)&&zyz2.equals(zyz)){
					flag=true;
				}
				if(schoolCode.equals(schoolCode2)&&majorCode.equals(majorCode2)&&zyz2.equals(zyz)){
					flag=true;
				}

				if(flag){

					SchoolPlan p=new SchoolPlan();
					p.setYear(year);
					p.setMajorType(majorType);

					p.setZyz(p2023.getZyz());
					p.setSchoolCode(p2023.getSchoolCode());
					p.setSchoolName(p2023.getSchoolName());

					p.setMajorCode(p2023.getMajorCode());
					p.setMajorName(p2023.getMajorName());
					p.setMajorSeq(p2023.getMajorSeq());

					p.setKm1(p2023.getKm1());
					p.setKm2(p2023.getKm2());
					p.setBatch("本科普通批");
					p.setKm21(p2023.getKm21());
					p.setKm22(p2023.getKm22());
					p.setKm23(p2023.getKm23());
					p.setMajorPm(p2023.getMajorPm());

					p.setMajorAdmin(admin2023.getAdmission());
					p.setMajorPlan(admin2023.getPlan());
					p.setMajorLowGrade(admin2023.getLowGrade());
					p.setMajorAvgGrade(admin2023.getAvgGrade());
					p.setMajorPm(p2023.getMajorPm());
					p.setMajorLowPm(admin2023.getLowGradeSeq());

					Integer low = admin2023.getLowGrade();
					if(low==null) low=0;
					Integer avg = admin2023.getAvgGrade();
					if(avg==null) avg=0;

					String privince = admin2023.getZxkm();
					System.out.println("------------------privince-------" + privince);
					if ("450000".equals(privince)) {//广西院校，用广西排名
						for (int j = 0; j < gradeList.size(); j++) {
							GkGradeDoc gradeDoc = gradeList.get(j);
							if (gradeDoc.getGrade().intValue() == low.intValue()) {
								// p.setMajorLowPm(gradeDoc.getSeq());
							}
							if (gradeDoc.getGrade().intValue() == avg.intValue()) {
								p.setMajorAvgPm(gradeDoc.getSeq());
							}
						}
					} else {//非广西院校，用全国排名
						for (int j = 0; j < gradeList2.size(); j++) {
							GkGradeDoc gradeDoc = gradeList2.get(j);
							if (gradeDoc.getGrade().intValue() == low.intValue()) {
								//  p.setMajorLowPm(gradeDoc.getSeq());
							}
							if (gradeDoc.getGrade().intValue() == avg.intValue()) {
								p.setMajorAvgPm(gradeDoc.getSeq());
							}
						}
					}

					addList.add(p);
					break;

				}


				if (addList.size() == 1000) {
					schoolPlanService.insertSchoolPlanAllList2(addList);
					addList.clear();
				}
			}


		}

		if(addList.size()>0) {

			schoolPlanService.insertSchoolPlanAllList2(addList);
		}

	}


	public void addSchoolPlanZyzPlan(Integer year,String majorType) {



		//广西排位分
		GkGradeDoc gkGradeDoc=new GkGradeDoc();
		gkGradeDoc.setYear(year);
		if("理工类".equals(majorType)) {
			gkGradeDoc.setGradeClass("工类");
		}
		if("文史类".equals(majorType)) {
			gkGradeDoc.setGradeClass("史类");
		}
		gkGradeDoc.setUseIn("广西");
		List<GkGradeDoc> gradeList=gkGradeDocService.selectGkGradeDocList(gkGradeDoc);


		//全国认可加分排位分
		gkGradeDoc=new GkGradeDoc();
		gkGradeDoc.setYear(year);
		if("理工类".equals(majorType)) {
			gkGradeDoc.setGradeClass("工类");
		}
		if("文史类".equals(majorType)) {
			gkGradeDoc.setGradeClass("史类");
		}
		gkGradeDoc.setUseIn("全国");
		List<GkGradeDoc> gradeList2=gkGradeDocService.selectGkGradeDocList(gkGradeDoc);



		List<SchoolPlan> addList=new ArrayList();

		SchoolZyzYearAdmission query=new SchoolZyzYearAdmission();
		query.setYear(year);
		query.setMajorType(majorType);
		List<SchoolZyzYearAdmission> zyzList = schoolZyzYearAdmissionService.selectSchoolZyzYearAdmissionList(query);

		SchoolPlan schoolPlanQuery=new SchoolPlan();
		schoolPlanQuery.setYear(year);
		schoolPlanQuery.setMajorType(majorType);
		List<SchoolPlan> list2023 = schoolPlanService.selectZyzAvgGradeList(schoolPlanQuery);
		for(int k=0;k<list2023.size();k++) {
			SchoolPlan p2023 = list2023.get(k);
			String privince = p2023.getSprovince();



			for (int i = 0; i < zyzList.size(); i++) {
				SchoolZyzYearAdmission zyz = zyzList.get(i);
				if (p2023.getSchoolCode().equals(zyz.getsCode())
						&& p2023.getMajorType().equals(zyz.getMajorType())
						&& p2023.getZyz().equals(zyz.getZyz())) {

					p2023.setZyzPlan(zyz.getPlan());
					p2023.setZyzAdmin(zyz.getAdmission());
					p2023.setZyzAvgGrade(zyz.getAvgGrade());
					p2023.setZyzLowGrade(zyz.getLowGrade());
					p2023.setZyzLowPm(zyz.getLowGradeSeq());

					break;
				}
			}

			//求平均分排名
			if(p2023.getZyzAvgGrade()!=null&&p2023.getZyzAvgGrade().intValue()>0) {
				if ("450000".equals(privince)) {//广西院校，用广西排名
					for (int j = 0; j < gradeList.size(); j++) {
						GkGradeDoc gradeDoc = gradeList.get(j);
						if (gradeDoc.getGrade().intValue() == p2023.getZyzAvgGrade().intValue()) {
							p2023.setZyzAvgPm(gradeDoc.getSeq());
						}
					}
				} else {//非广西院校，用全国排名
					for (int j = 0; j < gradeList2.size(); j++) {
						GkGradeDoc gradeDoc = gradeList2.get(j);
						if (gradeDoc.getGrade().intValue() == p2023.getZyzAvgGrade().intValue()) {
							p2023.setZyzAvgPm(gradeDoc.getSeq());
						}
					}
				}
			}


			addList.add(p2023);
			if (addList.size() == 1000) {
				schoolPlanService.updateSchoolPlanZyz2List(addList);
				addList.clear();
			}
		}

		if(addList.size()>0) {

			schoolPlanService.updateSchoolPlanZyz2List(addList);
		}



	}


}
